Skip to content

Commit

Permalink
ckeditor + admin them san pham (thieu subtitle)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinh2597 committed Jan 22, 2019
1 parent 596de0f commit de306da
Show file tree
Hide file tree
Showing 792 changed files with 21,935 additions and 282 deletions.
9 changes: 9 additions & 0 deletions .idea/DryFood.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

518 changes: 261 additions & 257 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function index()
{
$orders = Order::all();
// dd($orders[0]->order_product);
return view('admin.order_index', ['orders' => $orders]);
return view('admin.order.order_index', ['orders' => $orders]);
}

/**
Expand Down
57 changes: 47 additions & 10 deletions app/Http/Controllers/AdminProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace App\Http\Controllers;

use App\Product;
use App\Category;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class AdminProductController extends Controller
{
Expand All @@ -16,8 +18,8 @@ public function index()
{
$products = Product::all();
// dd($products[0]);
dd($products[0]->category->name);
return view('admin.product_index');
// dd($products[0]->category->name);
return view('admin.product.product_index', ['products' => $products]);
}

/**
Expand All @@ -27,24 +29,59 @@ public function index()
*/
public function create()
{
//
$categories = Category::all();
return view('admin.product.product_create', ['categories' => $categories]);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$request->validate([
'name' => 'required|string|max:255',
'category_id' => 'required|numeric|min:1',
'code' => 'required|string|max:255',
'old_price' => 'required|numeric|min:0',
'price' => 'required|numeric|min:0',
'description' => 'required|string',
'avatar' => 'required|image',
]);
if ($request->hasFile('avatar')) {
$avatar = Storage::disk('uploads')->put('avatar', $request->file('avatar'));
$images = '';
if ($request->hasFile('image')) {
foreach ($request->image as $key => $image) {
if($key==0){
$images .= '/uploadMedia/products/' . Storage::disk('uploads')->put('description', $image);
}
else $images .= ' | /uploadMedia/products/' . Storage::disk('uploads')->put('description', $image);
}
}
dd($request->all());
// dd(str_slug('â - bádl1s'));
$product = new Product;
$product->name = $request->input('name');
$product->url = str_slug($request->input('url').'-'.$request->input('code'));
$product->description = $request->input('description');
$product->code = $request->input('code');
$product->old_price = $request->input('old_price');
$product->price = $request->input('price');
$product->avatar = '/uploadMedia/products/' . $avatar;
$product->image = $images;
$product->category_id = $request->input('category_id');
$product->save();
return view('admin.product.product_create_success');
}
}

/**
* Display the specified resource.
*
* @param \App\Product $product
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function show(Product $product)
Expand All @@ -55,7 +92,7 @@ public function show(Product $product)
/**
* Show the form for editing the specified resource.
*
* @param \App\Product $product
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function edit(Product $product)
Expand All @@ -66,8 +103,8 @@ public function edit(Product $product)
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Product $product
* @param \Illuminate\Http\Request $request
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Product $product)
Expand All @@ -78,7 +115,7 @@ public function update(Request $request, Product $product)
/**
* Remove the specified resource from storage.
*
* @param \App\Product $product
* @param \App\Product $product
* @return \Illuminate\Http\Response
*/
public function destroy(Product $product)
Expand Down
2 changes: 1 addition & 1 deletion app/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Product extends Model
{
protected $table = "products";
protected $fillable = ['name', 'url', 'description', 'code', 'price', 'image', 'category_id'];
protected $fillable = ['name', 'url', 'subtitle', 'description', 'code', 'price', 'avatar', 'image', 'category_id'];
protected $guarded = ['id'];
public $timestamps = false;

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"license": "MIT",
"require": {
"php": "^7.1.3",
"ckfinder/ckfinder-laravel-package": "^3.4",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0"
Expand Down
Loading

0 comments on commit de306da

Please sign in to comment.