Роуты:
Route::get('admin/category',['uses'=>'admin\CatController@index', 'as'=>'category', 'middleware'=>'auhtgust']);
Route::post('admin/category',['uses'=>'admin\CatController@store', 'as'=>'categorystore', 'middleware'=>'auhtgust']);
Мой контролер:
<?php namespace App\Http\Controllers\admin;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Category;
class CatController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$Category = Category::all();
return view ('admin.Category', ['Category'=>$Category]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store( Request $request)
{
$Category = new Category();
$Category->name= $request->input('name');
$img=Input::file('img');
$filename=date('Y-m-d-H:i:s')."-".$img->getClientOriginalName();
Images::make($img->getRealPath())-resize(300,200)->save('public/site/img/category/'.$filename);
$path="public/site/img/category/";
$Category->img='site/img/category'.$filename;
$Category->save();
Flash::success('Категория добавленна.');
return redirect('admin/');
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
Мое представление:
{!! Form::open(['route'=>'categorystore','method' => 'POST', 'files' => true]) !!}
<div class="form-group">
<label>Имя категории:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user"></i>
</div>
{!! Form::text('name', null, ['class'=>'form-control pull-right' ]) !!}
</div>
</div>
<div class="form-group">
<label>Картинка:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-envelope-o"></i>
</div>
{!! Form::file('img', null, ['class'=>'form-control pull-right' ]) !!}
</div>
</div>
{!! Form::submit('Создать',['class'=>'btn btn-block btn-success']) !!}
{!! Form::close() !!}
Моя модель:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Category extends Model {
protected $table = 'categories';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'img'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['id', 'remember_token','_token',];
}
После того как я наживаю кнопку "Создать" - вижу белый экран. Не показывает даже ошибки.
Запись в БД не создается и картинки в папке нет.
В чем проблема?