sghimire

sghimire

Member Since 1 Year Ago

Experience Points 12,890
Experience
Level
Lessons Completed 124
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

27 Sep
2 months ago

sghimire left a reply on Run Artisan Command

Yes I am thinking to use ajax to check the file to let user know that the file is ready for them to download, however, is there anyway send the job in the background till the process finished?

many thanks!

26 Sep
2 months ago

sghimire left a reply on Run Artisan Command

When background process will be completed then User will be able to see the downloadable button, then hits the file buttons, and download the required file from the storage. That's way I am planning to deliver it to user. I will be happy to get any suggestion on this.

Cheers,

sghimire left a reply on Run Artisan Command

Thanks Snapey! I am trying to let the user to download their paginated search results in the file(in one go) so they can generate the file straight a way rather than running in the cron scheduler.

please can you give one example for your response as below

You do need to be using the queue properly though and not as sync, and with a queue worker.

Thanking in advanced!

25 Sep
2 months ago

sghimire started a new conversation Run Artisan Command

I have been trying to write a large file and calling artisan command from controller, command runs but I am getting time out all the time. Is there anyway to run this artisan command in queue from api(browser) then send it to run in the background like in the terminal, please?

---controller

Artisan::queue('test:ExecuteFile', ['filter' => $request->all(),'--queue' => $fileName]);

---app/Console/kernel.php

 public function queue($command, array $parameters = [], $queue = 'default')
    {
        $this->app['Illuminate\Contracts\Queue\Queue']->push(
            'Illuminate\Foundation\Console\QueuedJob', [$command, $parameters], $queue
        );
    }

---
public function handle()
{
        //getting the filter 
        $filter = $this->argument('filter');

        //getting optional values
        $queueName = $this->option('queue');
}
22 Jun
5 months ago

sghimire left a reply on Performing Concat On Where Clause

Thanks for your help!

21 Jun
5 months ago

sghimire left a reply on Performing Concat On Where Clause

Hi Snapey,

I am trying to do the concatenate "first_name and last_name" of customer but it is throwing error as below, please can you help on this.

$query = (new Order)->newQuery() ->select('concat(customer_contacts.first_name," ",customer_contacts.last_name)') ->join('samples', 'orders.id', '=', 'samples.order_id' ) ->join('assignments', 'samples.id', '=', 'assignments.sample_id' ) ->join('customer_contacts', 'orders.customer_contact_id', '=', 'customer_contacts.id' ) ->where('orders.id', '=', 1) ->whereNotNull('customer_contacts.email')->first(); } SQLSTATE[42S22]: Column not found: 1054 Unknown column 'concat(customer_contacts.first_name,\" \",customer_contacts.last_name)' in 'field list' (SQL: selectconcat(customer_contacts.first_name," ",customer_contacts.last_name)fromordersinner joinsamplesonorders.id=samples.order_idinner joinassignmentsonsamples.id=assignments.sample_idinner joincustomer_contactsonorders.customer_contact_id=customer_contacts.idwhereorders.id= 234877 andassignments.team_id= 4 andcustomer_contacts.emailis not null limit 1)

Thanking in advanced. Mani

22 May
6 months ago

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

Hi bashy,

Thanks for helping on my above query, however I am still having the problem with this validation. Please can you help.

Many thanks for your time.

21 May
6 months ago

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

Sorry for the confusion .. reports is array and it contains multiple values.

protected $rules = [

    'title'                                 =>'required|string|max:255',
    'slug'                                  =>"required|alpha_dash|min:5|max:255|unique:posts,slug",
    'image'                                 =>'sometimes|image', 
    'category_id'                       =>'required|integer',
    'reports'                               => 'sometimes',
    'reports.*.report_type_id'  => 'required|integer',

];

I have implemented as you suggested , however it is not working the validation for me, if I do not include the "report_type_id" as below:

"reports":[  
     {  
        "report":"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus",        
        "test_id": 388594
     },
      {  
        "report":"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo",
        "report_type_id":1,
        "test_id": 388595
     },
     
      {  
        "report":"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo",
        "report_type_id":2,
        "test_id": 388596
     }
    
  ],

It is throwing database(MYSQL) error but it is not triggering the validation at all.

{
"message": "Undefined index: report_type_id",
    "status_code": 500,
}

Thank you for your great help!

18 May
6 months ago

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

Thanks for you reply. However I am still getting the below message all the time. That means validation is trigger all the times. Please can you help.

{
    "message": {
        "reports": [
            "The reports field is required."
        ]
    }
}

sghimire left a reply on API Resources

Books and Author have many-to-many relationships. Author have many books and Books have many Author, that's why Pivot table(author_book) is created. It holds author and books primary keys as foreign keys. Please see my Laravel model as below:

//author.php public function author() { return $this->hasMany(AuthorBook::class); }

//book.php Public function book() { return $this->hasMany(AuthorBook::class); }

//authorBook.php Public function authors() { return $this->belongsTo(Author::class); }

Public function books() { return $this->belongsTo(Book::class); }

sghimire left a reply on API Resources

Book and author have got many-to-many relationship.

17 May
6 months ago

sghimire left a reply on Generating PDFs From Laravel Views And Trying To Save In Mysql Database

Thanks anyway- I am using postman to generate the pdf though.

sghimire left a reply on Generating PDFs From Laravel Views And Trying To Save In Mysql Database

Hi All,

I have managed to generate the pdf from the above code but I cannot open it and it was sent as an email attachment. Please can you help me on this.

16 May
6 months ago

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

protected $rules = [

    'title' =>'required|string|max:255',
    'slug' =>"required|alpha_dash|min:5|max:255|unique:posts,slug",
    'image' =>'sometimes|image', 'category_id' =>'required|integer',
    'reports.*.report_type_id' =>'required|integer',
];

I have tried as above but it did not work for me too.

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

protected $rules = [ 'title' =>'required|string|max:255', 'slug' =>"required|alpha_dash|min:5|max:255|unique:posts,slug", 'image' =>'sometimes|image', 'category_id' =>'required|integer', 'reports.id' =>'required|integer', ];

sghimire left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

Hi there,

In the below example the report is an array I want to write the rules to validate array Item i.e. report.id - is this possible to do it? if not please can you suggest me on this.

$rules = [ 'title' =>'required|string|max:255', 'slug' =>"required|alpha_dash|min:5|max:255|unique:posts,slug", 'image' =>'sometimes|image', 'category_id' =>'required|integer', 'report' =>'required' ];

Thanking in advanced!

13 May
7 months ago

sghimire left a reply on API Resources

The above are my model examples...

How can I include book resources when I am creating author resources api?

10 May
7 months ago

sghimire left a reply on Generating PDFs From Laravel Views

That's what I am doing right now. I want to save it to the database.

view()->share('lab',$data);
    $pdf = PDF::loadView('lab.test');
    return $pdf->download('test_'. $request['Id'] . '_lab.pdf');

sghimire left a reply on Generating PDFs From Laravel Views And Trying To Save In Mysql Database

That's what I am doing right now. I want to save it to the database.

view()->share('lab',$data);
    $pdf = PDF::loadView('lab.test');
    return $pdf->download('test_'. $request['Id'] . '_lab.pdf');

sghimire left a reply on Save PDF File With Dompdf

That's what I am doing right now. I want to save it to the database.

view()->share('lab',$data);
    $pdf = PDF::loadView('lab.test');
    return $pdf->download('test_'. $request['Id'] . '_lab.pdf');

sghimire left a reply on Generating PDFs From Laravel Views

Hi Guys,

Is there anyway generated PDF file(from a Laravel View) can be saved in the database?

sghimire started a new conversation Generating PDFs From Laravel Views And Trying To Save In Mysql Database

Hi all, I 've been using this library(https://github.com/barryvdh/laravel-dompdf) to generate PDF from a Laravel View and trying to save in the database.

Is there any methods to save the pdf in the database without saving in the file system?

Thanking in Advanced.

sghimire left a reply on Save PDF File With Dompdf

Is there anyway it can be saved in the database?

09 May
7 months ago

sghimire started a new conversation API Resources

Hi,

Please can you help on this- I am trying to to include book resources api when I am creating API resources for author. This two tables has many to many relationship.

Please see example as below:

//author.php public function author() { return $this-hasMany(AuthorBook::class); }

//book.php Public function book() { return $this-hasMany(AuthorBook::class); }

//authorBook.php Public function authors() { return $this->belongsTo(Author::class); }

Public function books() { return $this->belongsTo(Book::class); }

01 Feb
10 months ago

sghimire left a reply on Truncates Text Data From SQL Server

Please can you help me on my previous post as above.

30 Jan
10 months ago

sghimire left a reply on Truncates Text Data From SQL Server

Sorry for posting many times- I am unable to post sql query:

Yes, it is still truncating on retrieval of the results set. Please find the query I am running to retrieve the data in mssql server as below.

However I found the solution, it needs defining MSSQL server connection before executing the query. I.e use Illuminate\Support\Facades\DB;

DB::connection('mssqlMilan')->select('SET TEXTSIZE -1');

Which is not the ideal solution for me because every time I run this function/code TEXTSIZE needs to define before executing the query.

Is there a way to configure Laravel to automatically pull the entire data result without truncating it ?

sghimire left a reply on Truncates Text Data From SQL Server

Which is not the ideal solution for me because every time I run this function/code TEXTSIZE needs to define before executing the query.

Is there a way to configure Laravel to automatically pull the entire data result without truncating it ?

sghimire left a reply on Truncates Text Data From SQL Server

use Illuminate\Support\Facades\DB; DB::connection('mssqlMilan')->select('SET TEXTSIZE -1')

sghimire left a reply on Truncates Text Data From SQL Server

Yes, it is still truncating on retrieval of the results set. Please find the query I am running to retrieve the data in mssql server as below.

sghimire left a reply on Truncates Text Data From SQL Server

Sorry I am not able to post

27 Jan
10 months ago

sghimire left a reply on Truncates Text Data From SQL Server

80,072 characters strings but it could be longer than that. Is there a way to configure Laravel5.2 to pull the entire text data for that field without truncating?

sghimire left a reply on Truncates Text Data From SQL Server

Hi Sapey,

Thanks for your comments. I am querying as text value from mssql server but it is truncating before inserting to mysql database and not able to get whole text record value as a result set.

I was trying to SET TEXTSIZE to 2147483647 before executing the query in Larave 5.2. It did not work for me please need help.

26 Jan
10 months ago

sghimire started a new conversation Truncates Text Data From SQL Server

When querying to get data from MSSQL database, its text field data is truncating, and not able to display in the website.

I am using both databases connection (as below) to fetch the data from mssql database, and dumping in mysql database.

'connections' => [

    'mssqlMilan' => array(
        'driver'   => 'sqlsrv',
        'host'     => env('DB_DIAGDOMERO_HOST', ''),
        'port'     => env('DB_DIAGDOMERO_PORT', ''),
        'database' => env('DB_DIAGDOMERO_DB', ''),
        'username' => env('DB_DIAGDOMERO_USERNAME', ''),
        'password' => $pwd,
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'   => '',

    ),

    'mysqlMilan' => [
        'driver' => 'mysql',
        'host' => env('DB_DIAG_HOST', ''),
        'port' => env('DB_DIAG_PORT', '3306'),
        'database' => env('DB_DIAG_DATABASE', ''),
        'username' => env('DB_DIAG_USERNAME', ''),
        'password' => $pwd,
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

],

I have also updated my php.ini file and it is set to (mssql.textlimit' , '2147483647' and 'mssql.textsize' , '2147483647') but no luck.

Please can you help.