I have inserted value in database from the Model, here is the code:
Controller:
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');
}
}
}
Model:
class Movie extends Model
{
public function createMovie($input) {
return $this->insert($input); // I need to return last inserted id here
}
}
By using this insert method how can I get the last inserted id?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire