Answers for "how to use data from other controllers in laravel"

PHP
6

laravel access controller method from another controller

// Include the other controller in this controller
use App\Http\Controllers\TasksController;

// Instantiate other controller class in this controller's method
$tasks_controller = new TasksController;
// Use other controller's method in this controller's method
$tasks_controller->postNotification($comment_content, $author);
Posted by: Guest on May-16-2020
1

how to pass data to controller in laravel

$dept = DB::table('master_department')->get();
$design = DB::table('master_designation')->get();
return view('registration', ['dept' => $dept], compact('design'));

#if we send as array
@foreach($dept as $key=>$d)
	{{ $dept[$key]->dept_title }}
@endforeach

#if we send as compact object
@foreach($design as $deg)
	<option value="{{ $deg->id }}">{{ $deg->deg_title }}</option>							
@endforeach
Posted by: Guest on February-03-2021

Code answers related to "how to use data from other controllers in laravel"

Browse Popular Code Answers by Language