What do you want to save?
Add Code snippet
New code examples
-
PHP 2021-10-24 01:31:08
laravel sluggable
$ composer require cviebrock/eloquent-sluggable Add solution -
Other 2021-10-20 10:32:04
Laravel eloquent soft delete
/** in migrations this changes need to add for table we want to add soft delete (LARAVEL)*/ /** The migrations. START */ public function up() { Schema::table('users', function(Blueprint $table) { $table->softDeletes(); }); } /** The ... Add solution -
Other 2021-10-20 08:23:11
save multiple models at once
You can save multiple models at once using the saveMany function: $post = Post::find(1); $post->comments()->saveMany([ new Comment(['message' => 'This a new comment']), new Comment(['message' => 'Me too!']), new Comment(['message'... Add solution -
PHP 2021-10-19 01:45:07
how to extract code from controller to helpers or other method in laravel
I would agree that it really comes down to what you feel comfortable with,here is a list of options I see. 1) make it a public or protected function in your controller 2) put the function into a trait that you can then use anywhere you need it 3) create ... Add solution -
PHP 2021-10-17 18:37:14
eloquent with
use Illuminate\Database\Eloquent\Builder; // Retrieve posts with at least one comment containing words like foo%... $posts = App\Post::whereHas('comments', function (Builder $query) { $query->where('content', 'like', 'foo%'); })->get(); // Ret... Add solution -
Other 2021-10-15 01:50:08
update any field from request laravel
// app/controllers/GiftsController.php public function update($id) { // Grab all the input passed in $data = Input::all(); // Use Eloquent to grab the gift record that we want to update, // referenced by the ID passed to the REST endpoint $gif... Add solution
Best helpers
Ranking is empty