Filter data from DB.

Posted 4 months ago by ziben69

Hello guys,

my question is about laravel, eloquent filtering. I have table which have got records: id, firstname, lastname, email.

I know how to display all informations from table, but how can I modify it to this:

Display all e-mails that don't contain firstname and lastname. Something like this:

Table: personal_data firstname lastname email john doe [email protected] dennis rat [email protected] mia donut [email protected]

and i need to have result:

Result: [email protected]

rest of data to the trash. Can someone help me?

public function index(MailRepository $mailRepo)
        $mails = $mailRepo->getAll();
        return view('mails.list', [
            "mailList" => $mails

protected $model;

    public function getAll($columns = array('*'))
        return $this->model->get($columns);

~~~ Mail model:
protected $fillable = [
        'FirstName', 'LastName', 'Email',

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.