Abdel Maimouni Abdel Maimouni - 10 months ago 49
PHP Question

Add foreign key to request Laravel

what i am trying to achieve is :
User create a Delivery by a title input,

When the user send the request i want to get the users_id to add it to delivery table as a foreign key.
Here is the deliveries table

public function up()
Schema::create('deliveries', function (Blueprint $table) {

Schema::table('deliveries', function ($table) {


here is the DeliveryController


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use App\User;

class DeliveryController extends Controller
public function index()
return view('delivery.index');

public function create()
return view('delivery.create');

public function store(Request $request)
$this->validate($request, [
'title' => 'required'

$input = $request->all();

$input['users_id'] = Auth::user()->id;


return redirect()->back();



After weeks of researches i found That my Controller Missing This Line :

    use Illuminate\Support\Facades\Input;