Skip to content

Commit e7781de

Browse files
Merge pull request #52 from systeminc/development
Stable release to production
2 parents 2fd5471 + 3d66870 commit e7781de

File tree

76 files changed

+477
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+477
-282
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ Start package installation by running instal command below:
4444
php artisan laravel-admin:instal
4545
```
4646

47+
If our package update throws composer, please update dependency running commend below:
48+
49+
```php
50+
php artisan laravel-admin:update
51+
```
52+
4753
Note that this installation uses migrations, so you must run it from machine that has access to your database.
4854

4955
For instance, if you use Vagrant, you will have to do `vagrant ssh` first, go to your project directory, and run this instal command. The same way you run your standard Laravel's migration command.
5056

5157
## Usage
5258

53-
TODO
59+
Visit [wiki](https://github.com/systeminc/laravel-admin/wiki/Blog)
5460

5561
## Contributing
5662

src/Blog.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ public function __get($key)
2424
*
2525
* @return type
2626
*/
27-
public function posts()
27+
public function posts($url_key = false)
2828
{
29-
return new BlogPost();
29+
if ($url_key) {
30+
return BlogPost::whereUriId($url_key)->first();
31+
} else {
32+
return new BlogPost();
33+
}
3034
}
3135

3236
/**

src/BlogCategory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BlogCategory extends Model
1313
'excerpt',
1414
'description',
1515
'menu_order',
16-
'uri',
16+
'slug',
1717
'seo_title',
1818
'seo_description',
1919
'seo_keywords',

src/BlogPost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BlogPost extends Model
88
{
99
protected $fillable = [
1010
'blog_category_id',
11-
'uri_id',
11+
'slug',
1212
'title',
1313
'thumb',
1414
'content',

src/BlogPostComment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BlogPostComment extends Model
1414
'approved',
1515
];
1616

17-
public function article()
17+
public function post()
1818
{
1919
return $this->belongsTo('SystemInc\LaravelAdmin\BlogPost', 'blog_post_id');
2020
}

src/Console/UpdateCommand.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,18 @@ public function handle()
5757
$this->line('');
5858
$this->line('Updating Configuration...');
5959

60-
$config_changed = false;
61-
62-
$config = require __DIR__.'/../config/laravel-admin.php';
63-
$config_file = File::get(__DIR__.'/../config/laravel-admin.php');
64-
60+
$package_config = require __DIR__.'/../config/laravel-admin.php';
6561
$client_config = require base_path('config/laravel-admin.php');
6662

67-
foreach (config('laravel-admin') as $key => $value) {
68-
$config_file = str_replace($config[$key], $value, $config_file);
63+
$replaceConfig = array_replace_recursive(require __DIR__.'/../config/laravel-admin.php', config('laravel-admin'));
6964

70-
//CHECK IS CONFIG MERGE WITH CLIENT
71-
if (!isset($client_config[$key]) && !$config_changed) {
72-
$config_changed = true;
65+
foreach ($package_config as $key => $value) {
66+
if (!isset($client_config[$key])) {
67+
File::put(base_path('config/laravel-admin.php'), ("<?php \r\n\r\nreturn ".preg_replace(['/$([ ])/', '/[ ]([ ])/'], ' ', var_export($replaceConfig, true)).';'));
68+
$this->info('Config file ("config/laravel-admin.php") is merged, please see changes for new feature');
7369
}
7470
}
7571

76-
File::put(base_path('config/laravel-admin.php'), $config_file);
77-
78-
//IF CONFIG ARE MERGE WARM USER
79-
if ($config_changed) {
80-
$this->info('Config file ("config/laravel-admin.php") is merged, please see changes for new feature');
81-
}
82-
8372
$this->line('Updating Configuration Done!');
8473
$this->line('');
8574
$this->line('***');

src/Http/Controllers/Blog/BlogController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getPostNew(Request $request)
4343
{
4444
$post = new BlogPost();
4545
$post->title = 'New Article';
46-
$post->uri_id = 'new-post-'.time();
46+
$post->slug = 'new-post-'.time();
4747
$post->save();
4848

4949
return redirect($request->segment(1).'/blog/post-edit/'.$post->id);
@@ -87,6 +87,7 @@ public function postSave(Request $request, $post_id)
8787
$post->thumb = null;
8888
}
8989

90+
$post->slug = str_slug($request->slug);
9091
$post->save();
9192

9293
return redirect($request->segment(1).'/blog/post-edit/'.$post->id)->with('success', 'Saved successfully');

src/Http/Controllers/Blog/CategoriesController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ public function postSave(Request $request, $category_id)
8989

9090
$category->thumb = null;
9191
}
92-
//REPLACE URI
93-
$uri = strtolower($request->title);
94-
$category->uri = str_replace(' ', '-', $uri);
92+
//REPLACE slug
93+
$category->slug = str_slug($request->title);
9594

9695
$category->save();
9796

src/Http/Controllers/PagesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function postSave(Request $request)
7575
}
7676

7777
$page->elements_prefix = $this->sanitizeElements($request->elements_prefix);
78-
$page->uri_key = $this->sanitizeUri($request->uri_key);
78+
$page->slug = str_slug($request->slug);
7979

8080
$page->save();
8181

@@ -119,7 +119,7 @@ public function postUpdate(Request $request, $page_id)
119119
$page->fill($data);
120120

121121
$page->elements_prefix = $elements_prefix;
122-
$page->uri_key = $this->sanitizeUri($request->uri_key);
122+
$page->slug = str_slug($request->slug);
123123

124124
$page->save();
125125

src/Http/Controllers/Places/LocationsController.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function postSave(Request $request)
7575
$location->map_id = null;
7676
}
7777

78-
$location->key = $this->sanitizeUri($request->key);
78+
$location->key = str_slug($request->key);
7979
$location->save();
8080

8181
return redirect(config('laravel-admin.route_prefix').'/places/locations')->with('success', 'Saved successfully');
@@ -119,15 +119,23 @@ public function postUpdate(Request $request, $location_id)
119119
$location = Location::find($location_id);
120120
$location->fill($data);
121121

122-
$location->image = $this->saveImage($request->file('image'), 'locations');
123-
$location->thumb_image = $this->saveImage($request->file('thumb_image'), 'locations/thumb');
124-
$location->marker_image = $this->saveImage($request->file('marker_image'), 'locations/marker');
122+
if ($request->hasFile('image')) {
123+
$location->image = $this->saveImage($request->file('image'), 'locations');
124+
}
125+
126+
if ($request->hasFile('thumb_image')) {
127+
$location->thumb_image = $this->saveImage($request->file('thumb_image'), 'locations/thumb');
128+
}
129+
130+
if ($request->hasFile('marker_image')) {
131+
$location->marker_image = $this->saveImage($request->file('marker_image'), 'locations/marker');
132+
}
125133

126134
if ($request->map_id == 0) {
127135
$location->map_id = null;
128136
}
129137

130-
$location->key = $this->sanitizeUri($request->key);
138+
$location->key = str_slug($request->key);
131139

132140
if ($request->input('delete_image')) {
133141
if (Storage::exists($location->image)) {

0 commit comments

Comments
 (0)