Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ea9d89f
Update README.md
maki10 Oct 3, 2016
1d5ea92
Update README.md
maki10 Oct 3, 2016
4d49e08
Added foreign key check
maki10 Oct 3, 2016
91ec1f7
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
maki10 Oct 3, 2016
ed66ed3
Update README.md
maki10 Oct 3, 2016
f3b7b38
style changes
stevonakic Oct 4, 2016
9d45414
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
stevonakic Oct 4, 2016
7cccec3
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
maki10 Oct 4, 2016
97d3610
Added sanitizeKey for uri_id in blog,
maki10 Oct 4, 2016
17951e3
Added sanitizeUri for products,
maki10 Oct 4, 2016
8c1c9e6
Applied fixes from StyleCI
maki10 Oct 4, 2016
1fd8c86
Merge pull request #47 from systeminc/analysis-zGJblE
maki10 Oct 4, 2016
000e292
Updated product validation,
maki10 Oct 4, 2016
279f7c6
style changes
stevonakic Oct 4, 2016
debb878
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
stevonakic Oct 4, 2016
b1f39b9
Fixing misspell for location
maki10 Oct 4, 2016
ea8aced
Changed uri, uri_key, uri_id to slug
maki10 Oct 4, 2016
100a41f
Changed UpdateCommand,
maki10 Oct 5, 2016
a7e77aa
Applied fixes from StyleCI
maki10 Oct 5, 2016
a1a8c8b
Merge pull request #48 from systeminc/analysis-8n2Z7A
maki10 Oct 5, 2016
fcf1ba9
Fixing adding items to order,
maki10 Oct 6, 2016
13533ac
style change
stevonakic Oct 6, 2016
cd7fef6
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
stevonakic Oct 6, 2016
065a4f1
Retype misspell on page elements
maki10 Oct 6, 2016
df49324
Changed uri_key to slug
maki10 Oct 13, 2016
32d6f52
Added url for location
maki10 Dec 13, 2016
ff4243d
Merge branch 'development' of https://github.com/systeminc/laravel-ad…
maki10 Dec 13, 2016
063d8b0
Fixing delete image when location is updated
maki10 Dec 14, 2016
c2f5e28
Merge branch 'master' into development
MladenJanjetovic Dec 15, 2016
b82acf2
Update AdminServiceProvider.php
MladenJanjetovic Dec 15, 2016
3015400
Update LocationsController.php
MladenJanjetovic Dec 15, 2016
3d66870
Update 2016_12_13_143350_add_url_to_locations_table.php
MladenJanjetovic Dec 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ Start package installation by running instal command below:
php artisan laravel-admin:instal
```

If our package update throws composer, please update dependency running commend below:

```php
php artisan laravel-admin:update
```

Note that this installation uses migrations, so you must run it from machine that has access to your database.

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.

## Usage

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

## Contributing

Expand Down
8 changes: 6 additions & 2 deletions src/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public function __get($key)
*
* @return type
*/
public function posts()
public function posts($url_key = false)
{
return new BlogPost();
if ($url_key) {
return BlogPost::whereUriId($url_key)->first();
} else {
return new BlogPost();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/BlogCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BlogCategory extends Model
'excerpt',
'description',
'menu_order',
'uri',
'slug',
'seo_title',
'seo_description',
'seo_keywords',
Expand Down
2 changes: 1 addition & 1 deletion src/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BlogPost extends Model
{
protected $fillable = [
'blog_category_id',
'uri_id',
'slug',
'title',
'thumb',
'content',
Expand Down
2 changes: 1 addition & 1 deletion src/BlogPostComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BlogPostComment extends Model
'approved',
];

public function article()
public function post()
{
return $this->belongsTo('SystemInc\LaravelAdmin\BlogPost', 'blog_post_id');
}
Expand Down
23 changes: 6 additions & 17 deletions src/Console/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,18 @@ public function handle()
$this->line('');
$this->line('Updating Configuration...');

$config_changed = false;

$config = require __DIR__.'/../config/laravel-admin.php';
$config_file = File::get(__DIR__.'/../config/laravel-admin.php');

$package_config = require __DIR__.'/../config/laravel-admin.php';
$client_config = require base_path('config/laravel-admin.php');

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

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

File::put(base_path('config/laravel-admin.php'), $config_file);

//IF CONFIG ARE MERGE WARM USER
if ($config_changed) {
$this->info('Config file ("config/laravel-admin.php") is merged, please see changes for new feature');
}

$this->line('Updating Configuration Done!');
$this->line('');
$this->line('***');
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/Blog/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getPostNew(Request $request)
{
$post = new BlogPost();
$post->title = 'New Article';
$post->uri_id = 'new-post-'.time();
$post->slug = 'new-post-'.time();
$post->save();

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

$post->slug = str_slug($request->slug);
$post->save();

return redirect($request->segment(1).'/blog/post-edit/'.$post->id)->with('success', 'Saved successfully');
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Controllers/Blog/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public function postSave(Request $request, $category_id)

$category->thumb = null;
}
//REPLACE URI
$uri = strtolower($request->title);
$category->uri = str_replace(' ', '-', $uri);
//REPLACE slug
$category->slug = str_slug($request->title);

$category->save();

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function postSave(Request $request)
}

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

$page->save();

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

$page->elements_prefix = $elements_prefix;
$page->uri_key = $this->sanitizeUri($request->uri_key);
$page->slug = str_slug($request->slug);

$page->save();

Expand Down
18 changes: 13 additions & 5 deletions src/Http/Controllers/Places/LocationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function postSave(Request $request)
$location->map_id = null;
}

$location->key = $this->sanitizeUri($request->key);
$location->key = str_slug($request->key);
$location->save();

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

$location->image = $this->saveImage($request->file('image'), 'locations');
$location->thumb_image = $this->saveImage($request->file('thumb_image'), 'locations/thumb');
$location->marker_image = $this->saveImage($request->file('marker_image'), 'locations/marker');
if ($request->hasFile('image')) {
$location->image = $this->saveImage($request->file('image'), 'locations');
}

if ($request->hasFile('thumb_image')) {
$location->thumb_image = $this->saveImage($request->file('thumb_image'), 'locations/thumb');
}

if ($request->hasFile('marker_image')) {
$location->marker_image = $this->saveImage($request->file('marker_image'), 'locations/marker');
}

if ($request->map_id == 0) {
$location->map_id = null;
}

$location->key = $this->sanitizeUri($request->key);
$location->key = str_slug($request->key);

if ($request->input('delete_image')) {
if (Storage::exists($location->image)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Places/MapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function postSave(Request $request)
$map = new Map();
$map->fill($data);

$map->key = $this->sanitizeUri($request->key);
$map->key = str_slug($request->key);
$map->save();

return redirect(config('laravel-admin.route_prefix').'/places/maps')->with('success', 'Saved successfully');
Expand Down Expand Up @@ -105,7 +105,7 @@ public function postUpdate(Request $request, $map_id)
$map = Map::find($map_id);
$map->fill($data);

$map->key = $this->sanitizeUri($request->key);
$map->key = str_slug($request->key);
$map->save();

return back()->with('success', 'Saved successfully');
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Controllers/Shop/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public function postSave(Request $request, $category_id)

$category->thumb = null;
}
//REPLACE URI
$uri = strtolower($request->title);
$category->uri = str_replace(' ', '-', $uri);
//REPLACE slug
$category->slug = str_slug($request->title);

$category->save();

Expand Down
27 changes: 17 additions & 10 deletions src/Http/Controllers/Shop/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public function postSave(Request $request, $order_id)

$order->update($request->all());

if (empty($request->input('valid_until'))) {
if (empty($request->valid_until)) {
$order->valid_until = null;
}
if (empty($request->input('date_of_purchase'))) {
if (empty($request->date_of_purchase)) {
$order->date_of_purchase = null;
}

if (empty($request->get('show_shipping_address'))) {
if (empty($request->show_shipping_address)) {
$order->show_shipping_address = 0;
}

Expand Down Expand Up @@ -115,12 +115,19 @@ public function postSave(Request $request, $order_id)
public function postAddItem(Request $request, $order_id)
{
$order = Order::find($order_id);
$product = Product::find($request->input('product_id'));
$product = Product::find($request->product_id);

$item = OrderItem::create([
'order_id' => $order->id,
'product_id' => $product->id,
$item = OrderItem::whereProductId($request->product_id)->first();

if ($item) {
$item->quantity += 1;
} else {
$item = OrderItem::create([
'order_id' => $order->id,
'product_id' => $product->id,
'custom_price' => 0,
]);
}

$item->save();

Expand Down Expand Up @@ -161,9 +168,9 @@ public function postEditItem(Request $request, $item_id)
{
$item = OrderItem::find($item_id);

$item->quantity = $request->input('quantity');
$item->discount = $request->input('discount');
$item->custom_price = $request->input('custom_price');
$item->quantity = $request->quantity;
$item->discount = $request->discount;
$item->custom_price = $request->custom_price;

$item->save();

Expand Down
4 changes: 3 additions & 1 deletion src/Http/Controllers/Shop/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function getNew(Request $request)
{
$product = new Product();
$product->title = 'New product';
$product->slug = 'new-product-'.time();
$product->save();

$gallery = new Gallery();
Expand Down Expand Up @@ -80,7 +81,7 @@ public function getEdit($product_id)
public function postSave(Request $request, $product_id)
{
// validation
$validation = Validator::make($request->all(), ProductValidation::rules(), ProductValidation::messages());
$validation = Validator::make($request->all(), ProductValidation::rules($product_id), ProductValidation::messages());

if ($validation->fails()) {
return back()->withInput()->withErrors($validation);
Expand Down Expand Up @@ -121,6 +122,7 @@ public function postSave(Request $request, $product_id)
}
$product->pdf = null;
}
$product->slug = str_slug($request->slug);
$product->save();

return redirect($request->segment(1).'/shop/products/edit/'.$product->id)->with('success', 'Saved successfully');
Expand Down
1 change: 1 addition & 0 deletions src/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Location extends Model
{
protected $fillable = [
'title',
'url',
'key',
'map_id',
'description',
Expand Down
2 changes: 1 addition & 1 deletion src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Map extends Model
'longitude',
];

public function location()
public function locations()
{
return $this->hasMany('SystemInc\LaravelAdmin\Location', 'map_id');
}
Expand Down
8 changes: 7 additions & 1 deletion src/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ class OrderItem extends Model
{
public $timestamps = false;

protected $fillable = ['product_id', 'quantity'];
protected $fillable = [
'order_id',
'product_id',
'quantity',
'discount',
'custom_price',
];

public function order()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Page extends Model
protected $fillable = [
'title',
'elements_prefix',
'uri_key',
'slug',
'description',
'keyword',
'parent_id',
Expand All @@ -36,7 +36,7 @@ public function menu()

public function tree()
{
$pages = self::whereParentId(null)->orderBy('order_number')->get(['id', 'title', 'uri_key']);
$pages = self::whereParentId(null)->orderBy('order_number')->get(['id', 'title', 'slug']);

$tree = [];

Expand All @@ -59,19 +59,19 @@ private function getTreeBranch()
return [
'id' => $this->id,
'title' => $this->title,
'uri_key' => $this->uri_key,
'slug' => $this->slug,
'subpages' => $tree,
];
}

public function subpages()
{
return $this->whereParentId($this->id)->get(['id', 'title', 'uri_key']);
return $this->whereParentId($this->id)->get(['id', 'title', 'slug']);
}

public function child($parent_id)
{
$pages = self::whereParentId($parent_id)->orderBy('order_number')->get(['id', 'title', 'uri_key']);
$pages = self::whereParentId($parent_id)->orderBy('order_number')->get(['id', 'title', 'slug']);

$tree = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Product extends Model
'product_category_id',
'brand_id',
'title',
'url_id',
'slug',
'excerpt',
'description',
'long_description',
Expand Down
2 changes: 1 addition & 1 deletion src/ProductCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ProductCategory extends Model
'excerpt',
'description',
'menu_order',
'uri',
'slug',
'seo_title',
'seo_description',
'seo_keywords',
Expand Down
Loading