Skip to content

Commit d0ba677

Browse files
Merge pull request #1 from laravel-appkit/develop
Very Basic Locking Mechanisum
2 parents 3f41f9e + 4f169ed commit d0ba677

File tree

16 files changed

+70
-149
lines changed

16 files changed

+70
-149
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Documentation
4-
url: https://appkit.coutts.io/packages/:package_name/docs
4+
url: https://appkit.coutts.io/packages/lockable/docs
55
about: View the documentation
66

77
- name: Community
8-
url: https://appkit.coutts.io/packages/:package_name/community
8+
url: https://appkit.coutts.io/packages/lockable/community
99
about: Ask the community for help

.github/workflows/coding-standards.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check & fix styling
1+
name: Check & Fix Styling
22

33
on: [push]
44

@@ -20,4 +20,4 @@ jobs:
2020
- name: Commit changes
2121
uses: stefanzweifel/git-auto-commit-action@v4
2222
with:
23-
commit_message: Fix styling
23+
commit_message: Fix styling

.php_cs.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"7.4.13","version":"2.17.3","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["const","method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true},"hashes":{"tests\/database\/migrations\/2021_01_01_000000_create_articles_table.php":1906224168,"src\/Facades\/Lockable.php":1969634961,"src\/Lockable.php":3429273821,"src\/Traits\/Lockable.php":3743096533,"src\/LockableServiceProvider.php":1931141247,"tests\/database\/migrations\/2014_10_12_000000_create_users_table.php":2933585291,"tests\/database\/factories\/UserFactory.php":364335595,"tests\/Models\/User.php":1901976356,"tests\/LockableTest.php":2883837912}}
1+
{"php":"7.4.13","version":"2.17.3","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["const","method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true},"hashes":{"tests\/database\/migrations\/2021_01_01_000000_create_articles_table.php":3885317590,"src\/Facades\/Lockable.php":1969634961,"src\/Lockable.php":3429273821,"src\/Traits\/Lockable.php":3743096533,"src\/LockableServiceProvider.php":1931141247,"tests\/database\/migrations\/2014_10_12_000000_create_users_table.php":2933585291,"tests\/database\/factories\/UserFactory.php":364335595,"tests\/Models\/User.php":1901976356,"tests\/LockableTest.php":2883837912,"tests\/database\/factories\/ArticlesFactory.php":2293051357,"tests\/Models\/Article.php":376444782,"tests\/TestCase.php":1479180223}}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
All notable changes to `:package_name` will be documented in this file
3+
All notable changes to `lockable` will be documented in this file
44

55
## 1.0.0 - 201X-XX-XX
66

README.md

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,63 @@
1-
# Very short description of the package
1+
# Eloquent Lockable
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-appkit/:package_name.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/:package_name)
4-
[![Build Status](https://img.shields.io/github/workflow/status/laravel-appkit/:package_name/Automated%20Tests?style=flat-square)](https://github.com/laravel-appkit/:package_name/actions?query=workflow%3A%22Automated+Tests%22)
5-
[![Quality Score](https://img.shields.io/github/workflow/status/laravel-appkit/:package_name/Check%20&%20fix%20styling?label=code%20quality&style=flat-square)](https://github.com/laravel-appkit/:package_name/actions?query=workflow%3A%22Check+%26+fix+styling%22)
6-
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-appkit/:package_name.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/:package_name)
7-
[![Licence](https://img.shields.io/packagist/l/laravel-appkit/:package_name.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/:package_name)
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-appkit/lockable.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/lockable)
4+
[![Build Status](https://img.shields.io/github/workflow/status/laravel-appkit/lockable/Automated%20Tests?style=flat-square)](https://github.com/laravel-appkit/lockable/actions?query=workflow%3A%22Automated+Tests%22)
5+
[![Quality Score](https://img.shields.io/github/workflow/status/laravel-appkit/lockable/Check%20&%20fix%20styling?label=code%20quality&style=flat-square)](https://github.com/laravel-appkit/lockable/actions?query=workflow%3A%22Check+%26+fix+styling%22)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-appkit/lockable.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/lockable)
7+
[![Licence](https://img.shields.io/packagist/l/laravel-appkit/lockable.svg?style=flat-square)](https://packagist.org/packages/laravel-appkit/lockable)
88

9-
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
9+
Allows a user to acquire a lock on a model, which prevents anyone else from being able to edit it.
1010

1111
## Installation
1212

1313
You can install the package via composer:
1414

1515
```bash
16-
composer require laravel-appkit/:package_name
16+
composer require laravel-appkit/lockable
1717
```
1818

1919
## Usage
2020

21+
Add the `AppKit\Lockable\Traits\Lockable` trait to the model you want to set locks on
22+
23+
Add a `locked_by` integer column to the corresponding table. This can also be done using the `lockable` method on the migration.
24+
2125
``` php
22-
// Usage description here
26+
<?php
27+
28+
namespace App\Models;
29+
30+
use AppKit\Lockable\Traits\Lockable;
31+
use Illuminate\Database\Eloquent\Model;
32+
33+
class Article extends Model
34+
{
35+
use Lockable;
36+
37+
/**
38+
* The attributes that are mass assignable.
39+
*
40+
* @var array
41+
*/
42+
protected $fillable = [
43+
'title',
44+
'body'
45+
];
46+
}
47+
```
48+
49+
### Acquiring Locks
50+
To acquire a lock on a model, call the `acquireLock` method on it.
51+
52+
```php
53+
$article->acquireLock();
2354
```
55+
### Releasing Locks
56+
To release the existing lock on a model, call the `releaseLock` method on it.
2457

58+
```php
59+
$article->releaseLock();
60+
```
2561
### Testing
2662

2763
``` bash

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "laravel-appkit/:package_name",
2+
"name": "laravel-appkit/lockable",
33
"description": "",
44
"keywords": [
55
"laravel",
66
"appkit",
7-
":package_name"
7+
"lockable"
88
],
9-
"homepage": "https://github.com/laravel-appkit/:package_name",
9+
"homepage": "https://github.com/laravel-appkit/lockable",
1010
"license": "MIT",
1111
"type": "library",
1212
"authors": [
@@ -27,12 +27,12 @@
2727
},
2828
"autoload": {
2929
"psr-4": {
30-
"AppKit\\:package_name_php\\": "src"
30+
"AppKit\\Lockable\\": "src"
3131
}
3232
},
3333
"autoload-dev": {
3434
"psr-4": {
35-
"AppKit\\:package_name_php\\Tests\\": "tests"
35+
"AppKit\\Lockable\\Tests\\": "tests"
3636
}
3737
},
3838
"scripts": {
@@ -42,10 +42,10 @@
4242
"extra": {
4343
"laravel": {
4444
"providers": [
45-
"AppKit\\:package_name_php\\:package_name_phpServiceProvider"
45+
"AppKit\\Lockable\\LockableServiceProvider"
4646
],
4747
"aliases": {
48-
":package_name_php": "AppKit\\:package_name_php\\Facades\\:package_name_php"
48+
"Lockable": "AppKit\\Lockable\\Facades\\Lockable"
4949
}
5050
}
5151
}

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
* :package_name configuration
4+
* lockable configuration
55
*/
66
return [
77

src/Facades/Blameable.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Package.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/PackageServiceProvider.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)