Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel delete relationship data

class User extends Eloquent
{
    public function photos()
    {
        return $this->has_many('Photo');
    }

    // this is a recommended way to declare event handlers
    public static function boot() {
        parent::boot();

        static::deleting(function($user) { // before delete() method call this
             $user->photos()->delete();
             // do the rest of the cleanup...
        });
    }
}
Comment

get relationship data from soft delete laravel

I already fixed it. In my model history I add withtrashed.

public function history()
{
    return $this->hasMany(History::class)->withTrashed();
}
Comment

PREVIOUS NEXT
Code Example
Php :: sum of multidimensional array in php 
Php :: how to create laravel project 
Php :: php get this week date range 
Php :: jquery serialize php decode 
Php :: get user information woocommerce 
Php :: print array in php 
Php :: laravel eloquent select case when 
Php :: laravel routing techniques 
Php :: resource controller artisan command 
Php :: remove string after comma in php 
Php :: gd php extension 
Php :: how to serve the port in php 
Php :: show only 3 initial letter of month in php 
Php :: php array to object 
Php :: display image from database in laravel 
Php :: php switch case array 
Php :: convert string to float in php 
Php :: laravel datepicker date format 
Php :: cache an array 
Php :: laravel set a session variable 
Php :: wordpress add meta user 
Php :: comments in php 
Php :: hoew to store a cookie php 
Php :: guzzle http client 
Php :: how to remove array index from json in php 
Php :: wordpress single post template 
Php :: double where condition in laravel 
Php :: Remove last symbol from string 
Php :: php add element to beginning of associative array 
Php :: php remove non utf-8 characters 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =