I'm new at laravel, and i have some problem to manage relationship with model and controller.
I have indexcontroller, where called:
$usersModel = new \App\Models\Users();
if ($usersModel->checkOnExistsByEmail($params['user_email'])){
//...find it
}
Model file:
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Users extends Model {
protected $table = 'users_data';
public function scopeCheckOnExistsByEmail($query,$email){
$count = $query->where('user_email','=',$email)->count();
if ($count == 0){
return false;
}else{
return true;
}
}
}
After that i've got an a error:
Object of class Illuminate\Database\Eloquent\Builder could not be converted to string
Could someone explain whats i do wrong? Thank you very much.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire