刀片文件
<div class="col-md1 simpleCart_shelfItem">
<a href="single.html">
@foreach(explode('|', $product->image) as $image))
<img class="img-responsive" src="{{url('/uploads'.'/'.$product->image)}}" alt="" />
@endforeach
</a>
<h3><a href="single.html">{{$products->name}}</a></h3>
<div class="price">
<h5 class="item_price">{{$products->price}}</h5>
<a href="#" class="item_add">Add To Cart</a>
<div class="clearfix"> </div>
</div>
</div>
产品负责人
public function store(Request $request){
//validate the form
$request->validate([
'name'=>'required',
'price'=>'required',
'description'=>'required',
'categories'=>'required',
'image'=>['required:image']
]);
//upload the image
$image=array();
if($files=$request->file('image')){
foreach($files as $file){
$name=$file->getClientOriginalName();
$file->move('uploads',$name);
$image[]=$name;
}
}
}
型号
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $guarded=[];
public function subcategory(){
return $this->hasMany('App\Product', 'categories');
}
}