Mehdi

Mehdi

Member Since 4 Years Ago

Experience Points 2,000
Experience Level 1

3,000 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 31
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

14 Apr
4 years ago

Mehdi started a new conversation Sql Query To Eloquent Query

Please i would to transalate my sql query to an eloquent query bacause i want to get an object as result not array

the sql query is :

select trx.* from trxcashin trx
left join userprofile prf on prf.profile = 0 and prf.network_id=trx.network_id and prf.network_acquirer_user_id=trx.acquirer_point_w
where trx.network_id='01'

that's what i do but it doesn't work

return Transaction::with(array(
            'user' => function($query){
                $query->select(array('name','surname'))
                    ->whereRaw("profile = 0 and network_id = ?", array($this->user->rest_entity_id));
            }
        ))->where('network_id', $this->user->rest_entity_id)->get();

My relation in the two models (Transaction and User) :

Transaction model :

 public function user(){
        return $this->belongsTo('User', 'acquirer_point_w', 'network_acquirer_user_id', '!=');

    }

User model :

public function transactions(){
        return $this->hasMany('Transaction', 'acquirer_point_w', 'network_acquirer_user_id');
    }

Thank's

21 Jan
4 years ago

Mehdi left a reply on Eloquent And Postgresql Incrementing

Thank's @lpadilla for your reply.

The probleme was, for whatever reason, the id can't be generated/incremented by postgresql.

So I creat a function who do this stuff :

'sq_statementcont_seq' is the name of my sequencer for this table.


/** * @return int */ protected function getNextStatementId() { $next_id = \DB::select("select nextval('sq_statementcont_seq')"); return intval($next_id['0']->nextval); }

Mehdi left a reply on Eloquent And Postgresql Incrementing

I have already tried :

/**
* @var array
*/
protected $guarded = array('id');

But still the same error !

Mehdi left a reply on Eloquent And Postgresql Incrementing

Or with Eloquent :

$message = new \EbrizMessenger();
$message->user_code_sender = $this->user->user_code;
$message->broadcasting_category = $input['broadcasting_category'];

$message->priority = $input['priority'];
$message->subject = $input['subject'];
$message->message = $input['message'];
$message->message_sending_date = date("Y-m-d H:i:s");
$message->save()

Mehdi left a reply on Eloquent And Postgresql Incrementing

That's my model :


<?php Class EbrizMessenger extends Eloquent{ /** * @var string */ protected $table = 'ebrizmessenger'; /** * @var string */ protected $primaryKey = 'id'; /** * @var bool */ public $timestamps = false; }

That's what i try to do :

$data = [
            'user_code_sender' => $this->user->user_code,
            'broadcasting_category' => $input['broadcasting_category'],
            'priority' => $input['priority'],
            'subject' => $input['subject'],
            'message' => $input['message'],
            'message_sending_date' => date("Y-m-d H:i:s"),
        ];
        if($input['broadcasting_category'] == '2')
        {
            $data['entity_id'] = $this->user->rest_entity_id;
            $data['auto_hide_datetime'] = date("Y-m-d H:i:s", strtotime("+1 week"));
        }

        if($input['broadcasting_category'] == '0')
            $data['user_code_receiver'] = $input['user_code_receiver'];

        \DB::table('ebrizmessenger')->insert($data);

Mehdi started a new conversation Eloquent And Postgresql Incrementing

Hello everyone, I work on application that uses a database already created with postgresql. I try to insert a new record in a table, using Eloquent and Query Builder. But I have the following error: Imgur Id of this database is auto-increment type. Any ideas !?

23 Oct
4 years ago

Mehdi left a reply on Manage Versioning For Laravel Project

Thank you guys for your answers.

I knew Git / GitHub, but I've never use it. And what I really wanted to know is how to manage private repositories for free (thanks @MThomas for the link).

@jrean your link well be very helpful on my git learning. Thank you very much.

22 Oct
4 years ago

Mehdi left a reply on Manage Versioning For Laravel Project

Thanks for your effort @jrean, but my question was how to manage my own code, my project, not a laravel dev branch.

Example : how @jeffrey manage versions of laracasts.com.

Mehdi started a new conversation Manage Versioning For Laravel Project

Hello. I want to manage versioning for my project based on laravel, how can I do ? Thanks,

Mehdi started a new conversation Genereate Documentation For My Code On Laravel

Hello, Who know how to generate a documentation from my own code into laravel ? Thnks,

16 Oct
4 years ago

Mehdi left a reply on Eloquent : Count Of Posts For A Period With One Row Per Day

i find the solution :

DB::raw('EXTRACT(MONTH FROM create_at) AS month'),

MONTH function apparently does not exist in PostgreSql. Thank you for your help.

Mehdi left a reply on Eloquent : Count Of Posts For A Period With One Row Per Day

the database is created manually, "create_at" represents "created_at" I use PostegreSQL

Mehdi left a reply on Eloquent : Count Of Posts For A Period With One Row Per Day

I do it, but still the same error !

Undefined function: 7 ERROR: function month(timestamp without time zone) does not exist LINE 1...

Mehdi left a reply on Eloquent : Count Of Posts For A Period With One Row Per Day

Thank you @Mushr00m four your reply : That's what i get with DB::raw('MONTH(created_at) AS month')

SQLSTATE[42883]: Undefined function: 7 ERROR: function month(timestamp without time zone) does not exist LINE 1: select MONTH(create_at) AS month, COUNT(*) AS count from "vi... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. (SQL: select MONTH(create_at) AS month, COUNT(*) AS count from "view_resacashin" where "create_at" between 2014-05-16 and 2014-10-16 group by "month" order by "month" asc)

That's what i do :

        $from = date('Y-m-d', strtotime('-5 month'));
        $to = date('Y-m-d');

        $chartDatas = Reservation::select([
            DB::raw('MONTH(create_at) AS month'),
            DB::raw('COUNT(*) AS count'),
        ])
            ->whereBetween('create_at', [$from, $to])
            ->groupBy('month')
            ->orderBy('month', 'ASC')
            ->lists('count', 'date');

        echo '<pre>';
        echo count($chartDatas);
        print_r($chartDatas);exit;

Mehdi left a reply on Eloquent : Count Of Posts For A Period With One Row Per Day

Hi, thank you guys for your replies.

I want to do the same but select by month.

Anyone can help me please ?

29 Sep
4 years ago

Mehdi started a new conversation English Subtitle For Videos

Hi Jeff, Hi laracsts lovers I just subscribed to your wonderful web site, and I really want to thank you for the effort you provided in the explanation. Jeff, I think many of your subscribers are not English or American who can speak or understand English easily, I would have liked if it's possible to add subtitles in English to your next videos. Thank's