6
6
[ ![ Total Downloads] ( https://img.shields.io/packagist/dt/chrisjk123/laravel-blogger.svg?style=flat-square )] ( https://packagist.org/packages/chrisjk123/laravel-blogger )
7
7
8
8
9
- This package is a blogging database with maxed out models, migrations and seeders to help get you setup. After the package is installed the only thing you have to do is add the ` Chrisjk123\Blogger\Traits\User\ HasPosts` trait to an Eloquent model to associate the users.
9
+ This package is a blogging database with maxed out models, migrations and seeders to help get you setup. After the package is installed the only thing you have to do is add the ` HasPosts ` trait to an Eloquent model to associate the users.
10
10
11
11
Here are some code examples:
12
12
13
13
``` php
14
14
// Search by the short whereCategories method OR use whereCategory() and specify the field
15
- $results = Chrisjk123\Blogger\ Post::whereCategories($categories = null)->get();
16
- $results = Chrisjk123\Blogger\ Post::whereCategory($field, $operator, $value)->get();
15
+ $results = Post::whereCategories($categories = null)->get();
16
+ $results = Post::whereCategory($field, $operator, $value)->get();
17
17
18
18
// Search by Category ID OR IDs
19
- $results = Chrisjk123\Blogger\ Post::whereCategories(1)->get();
20
- $results = Chrisjk123\Blogger\ Post::whereCategory('id', 1)->get();
19
+ $results = Post::whereCategories(1)->get();
20
+ $results = Post::whereCategory('id', 1)->get();
21
21
----------
22
- $results = Chrisjk123\Blogger\ Post::whereCategories([3, 6, 7])->get();
23
- $results = Chrisjk123\Blogger\ Post::whereCategory('id', [3, 6, 7])->get();
22
+ $results = Post::whereCategories([3, 6, 7])->get();
23
+ $results = Post::whereCategory('id', [3, 6, 7])->get();
24
24
25
25
// Search by Category name OR names
26
- $results = Chrisjk123\Blogger\ Post::whereCategories('Izabella Bins II')->get();
27
- $results = Chrisjk123\Blogger\ Post::whereCategory('name', 'Izabella Bins II')->get();
26
+ $results = Post::whereCategories('Izabella Bins II')->get();
27
+ $results = Post::whereCategory('name', 'Izabella Bins II')->get();
28
28
----------
29
- $results = Chrisjk123\Blogger\ Post::whereCategories(['Izabella Bins II', 'Osborne Fay'])->get();
30
- $results = Chrisjk123\Blogger\ Post::whereCategory('name', ['Izabella Bins II', 'Osborne Fay'])->get();
29
+ $results = Post::whereCategories(['Izabella Bins II', 'Osborne Fay'])->get();
30
+ $results = Post::whereCategory('name', ['Izabella Bins II', 'Osborne Fay'])->get();
31
31
32
32
// Search by Category model or a Category Collection
33
- $category = Chrisjk123\Blogger\ Category::where('id', 7)->first();
34
- $results = Chrisjk123\Blogger\ Post::whereCategories($category)->get();
33
+ $category = Category::where('id', 7)->first();
34
+ $results = Post::whereCategories($category)->get();
35
35
----------
36
- $categories = Chrisjk123\Blogger\ Category::whereIn('id', [3, 6, 7])->get();
37
- $results = Chrisjk123\Blogger\ Post::whereCategories($categories)->get();
36
+ $categories = Category::whereIn('id', [3, 6, 7])->get();
37
+ $results = Post::whereCategories($categories)->get();
38
38
39
39
// Search by related Post (tags or category)
40
- $post = Chrisjk123\Blogger\ Post::find(8);
41
- $results = Chrisjk123\Blogger\ Post::relatedByPostTags($post)->get();
40
+ $post = Post::find(8);
41
+ $results = Post::relatedByPostTags($post)->get();
42
42
----------
43
- $results = Chrisjk123\Blogger\ Post::relatedByPostCategory($post)->get();
43
+ $results = Post::relatedByPostCategory($post)->get();
44
44
45
45
// Search by published Posts only
46
- Chrisjk123\Blogger\ Post::published()->get();
46
+ Post::published()->get();
47
47
----------
48
- Chrisjk123\Blogger\ Post::publishedLastMonth()->get();
48
+ Post::publishedLastMonth()->get();
49
49
----------
50
- Chrisjk123\Blogger\ Post::publishedLastWeek()->get();
50
+ Post::publishedLastWeek()->get();
51
51
52
52
// Search by unpublished Posts only
53
- Chrisjk123\Blogger\ Post::notPublished()->get();
53
+ Post::notPublished()->get();
54
54
55
55
// Search by scheduled Posts only
56
- Chrisjk123\Blogger\ Post::scheduled()->get();
56
+ Post::scheduled()->get();
57
57
58
58
// Search by drafted Posts only
59
- Chrisjk123\Blogger\ Post::draft()->get();
59
+ Post::draft()->get();
60
60
61
61
// Order by latest published
62
- Chrisjk123\Blogger\ Post::orderByLatest()->get();
62
+ Post::orderByLatest()->get();
63
63
```
64
64
65
65
## Requirements
@@ -77,7 +77,7 @@ composer require chrisjk123/laravel-blogger
77
77
You can publish the migrations with:
78
78
79
79
``` bash
80
- php artisan vendor:publish --provider=" Chrisjk123\Blogger \BloggerServiceProvider" --tag=" migrations"
80
+ php artisan vendor:publish --provider=" Chriscreate\Blog \BloggerServiceProvider" --tag=" migrations"
81
81
```
82
82
83
83
Publish the migrations:
@@ -86,16 +86,36 @@ Publish the migrations:
86
86
php artisan migrate
87
87
```
88
88
89
+ You can optionally publish the config file with:
90
+
91
+ ``` bash
92
+ php artisan vendor:publish --provider=" Chriscreate\Blog\BloggerServiceProvider" --tag=" config"
93
+ ```
94
+
95
+ This is the contents of the published config file, if your ` User ` class is
96
+ within a different directory, you can change it here as well as the User primary key:
97
+
98
+ ``` php
99
+ return [
100
+ /*
101
+ * The default path to the User model in Laravel
102
+ */
103
+ 'user_class' => \App\User::class,
104
+ 'user_key_name' => 'id',
105
+ ];
106
+
107
+ ```
108
+
89
109
You can publish the factories with:
90
110
91
111
``` bash
92
- php artisan vendor:publish --provider=" Chrisjk123\Blogger \BloggerServiceProvider" --tag=" factories"
112
+ php artisan vendor:publish --provider=" Chriscreate\Blog \BloggerServiceProvider" --tag=" factories"
93
113
```
94
114
95
115
You can publish the seeder with:
96
116
97
117
``` bash
98
- php artisan vendor:publish --provider=" Chrisjk123\Blogger \BloggerServiceProvider" --tag=" seeders"
118
+ php artisan vendor:publish --provider=" Chriscreate\Blog \BloggerServiceProvider" --tag=" seeders"
99
119
```
100
120
101
121
## Documentation
@@ -105,7 +125,7 @@ All you have to do is add the `HasPosts` to your User model to get started.
105
125
``` php
106
126
namespace App;
107
127
108
- use Chrisjk123\Blogger \Traits\User\HasPosts;
128
+ use Chriscreate\Blog \Traits\User\HasPosts;
109
129
use Illuminate\Foundation\Auth\User as Authenticatable;
110
130
use Illuminate\Notifications\Notifiable;
111
131
0 commit comments