jeudi 11 mars 2021

use data field in controller for another crud

how are you ?

I have User CRUD and there is field on it for user mobile number : Id : 1 Name : test Mobile: 5555555 ,

and also I have another CRUD for Bookings , Booking CRUD has field to link the user called user_id

now i'm in Bookings CRUD controller and I want to send sms for the mobile of the user who made this booking

so first I add in Bookings Model this function

public function mobile()
    {
        return $this->belongsTo(User::class, 'mobile');
    }

and in the Bookings controller

$booking_mobile = User::all()->pluck('mobile', 'id');

but the value of the $booking_mbile not what i want it to be

I want to to be the the mobile number from the User CRUD for the user_id who in the Bookings CRUD



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire