I'm creating a website by using Laravel 5.3. There is a problems about database connection. I have 2 independent tables called languages and documents when I retrieve data from these tables the problems happen. Here is my code in language controller
use App\Languages;
use Illuminate\Support\Facades\DB;
class LanguageController extends Controller {
public function getLanName(){
$lans = Languages::all();
return view('index',compact('lans'));
}
}
and here is the code of language model
namespace App;
use Illuminate\Database\Eloquent\Model;
class Languages extends Model{
protected $table = 'languages';
public $timestamps = true;
protected $primaryKey = 'lan_id';
}
the Document controller and model are same as language
namespace App\Http\Controllers;
use App\Documents;
use Illuminate\Support\Facades\DB;
class DocumentController extends Controller{
public function getDocName(){
$docs = Documents::all();
return view('index',compact('docs'));
}
}
and this is my route and some of html in the view:
Route::get('/',['uses' => 'DocumentController@getDocName']);
Route::get('/',['uses' => 'LanguageController@getLanName']);
<select >
<option >Select Document</option>
@foreach($docs as $doc)
<option value="{{$doc->docName}}">{{$doc->docName}} </option>
@endforeach
</select>
<select>
<option >Select Language</option>
@foreach($lans as $lan)
<option value="{{$lan->language}}">{{$lan->language}}</option>
@endforeach
</select>
I can only retrieve either language or document. If I comment language or document, the other one works well.Can't I use two controller in same route?
Many Thanks to help..