There are a few methods in doing this:
Static method in your model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Users_Model extends Model
{
//
protected $table = 'inh';
public static function login_validate()
{
return "Hello!";
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Users_Model;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class LoginController extends Controller
{
public function getLogin() {
return view('pages.login');
}
public function sample(){
$sample_two = Users_Model::login_validate();
echo $sample_two;
}
}
Resolve the model in the container
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Users_Model extends Model
{
//
protected $table = 'inh';
public function login_validate()
{
return "Hello!";
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Users_Model;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class LoginController extends Controller
{
public function getLogin() {
return view('pages.login');
}
public function sample(Users_Model $usersModel){
$sample_two = $usersModel->login_validate();
echo $sample_two;
}
}
I see now. So you need to pass the Name of the Model into the Parameters of my Function? :)
I'll give this a try and give you a fast response. Thank you moinescumihai! :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community