title: How to fetch the data from the master table in model and use in another model in laravel?
body: <blockquote>
    <p>Here is my one model name "Department"</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Department extends Model
  {
      //
       protected $table = 'dept_master';
  }
  </code></pre>
  
  <blockquote>
    <p>and the controller of the department is</p>
  </blockquote>
  
  <p>namespace App\Http\Controllers;</p>
  
  <pre><code>use Illuminate\Http\Request;
  use Illuminate\Support\Facades\DB;
  
  
  
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  
  use App\Department;
  
  class DepartmentController extends Controller
  {
      public function departmentsName()
      {
  
          $departments = DB::table('dept_master')-&gt;orderBy('edesc','ASC')-&gt;get();
          return $departments;
      }
  }
  </code></pre>
  
  <blockquote>
    <p>and another model grievance register</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
      namespace App;
      //namespace Models;
  
      use Illuminate\Database\Eloquent\Model;
  
  
      class GrievanceRegister extends Model
      {
  
      }
  </code></pre>
  
  <blockquote>
    <p>and the grievance controller is</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use Illuminate\Support\Facades\DB;
  use Illuminate\Http\Request;
  
  
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  
  use App\GrievanceRegister;
  use App\Department;
  
  class GrievanceRegisterController extends Controller
  {
     public function show()
     {
    $departments = Department::orderBy('edesc','ASC')-&gt;get();
    return view('griev_reg_form', array('departments' =&gt; $departments));
  }
  
  }
  
     ?&gt;
  </code></pre>
  
  <blockquote>
    <p>and in the view file</p>
  </blockquote>
  
  <pre><code> &lt;select name="departments"&gt; &lt;?php foreach($departments as $result)
                  {
                      ?&gt; &lt;option value="&lt;?php echo $result-&gt;deptcode; ?&gt;"&gt;&lt;?php echo $result-&gt;edesc; ?&gt;&lt;/option&gt;  &lt;?php   }       ?&gt;
                      &lt;/select&gt;
  </code></pre>
  
  <blockquote>
    <p>Is it a correct way to call one model data from another model and
    controller. Please correct me if am wrong.</p>
  </blockquote>