Posts

Showing posts from May, 2017

DB::statement(); for serial in table

DB::statement(DB::raw('set @serial=0')); $list = Designation::orderBy('id','desc')          ->get([          'id',          'title',          DB::raw('@serial := @serial +1 as serial')           ]);

Getting key from an array by value

if(in_array($data['question_type],$questionTypes)){    $examTypeId = array_search($data['question_type'],$questionTypes); }

Object to array conversion

$examTypes = ExamType::lsits('exam_name','id'); $questionTypes = json_decode(json_encode($examTypes), True );

List Query for select box in Laravel

ExamType::lists('exam_name','id');

Git credentials storing in cache

Windows git config --global credential.helper wincred git pull origin <enter your branch> Username: <type your username> Password: <type your password> Ubuntu git config credential.helper store git pull origin <enter your branch> Username: <type your username> Password: <type your password> Fedora git config --global credential.helper gnome-keyring git pull origin <enter your branch> Username: <type your username> Password: <type your password>

MySQL Commands

-> To set set primary key in a table alter table tableName add primary key(id); -> To remove primary key from a table alter table tableName drop primary key; -> To set a default value for column alter table tableName alter column fieldName set default AnyDefaultValue.

Run project in custom host and custom port

Running Laravel Project php artisan serve --host=192.168.200.100 --port=8000 Normally php -S localhost:8080 -t public