我從Model
插入數據庫值,這裏是代碼:如何從插入方法laravel得到最後插入的ID 5.1
控制器:
class MovieController extends Controller
{
/**
* Create a new movie model instance.
*
* @return void
*/
public function __construct(MovieModel $movie){
$this->movie = $movie;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(MovieRequest $request)
{
if($this->movie->createMovie($input)){
return Redirect::back()->with('message', '<strong>' . $input['name'] . '</strong> movie has been created');
}
}
}
型號:
class Movie extends Model
{
public function createMovie($input) {
return $this->insert($input); // I need to return last inserted id here
}
}
通過使用此插入方法我怎樣才能得到最後插入的ID?
顯示您的插入功能代碼.. –
我打電話給laravel插入功能照亮 –