aspiresuvedi

aspiresuvedi

Member Since 4 Years Ago

Pokhara

Software Developer at Kathmandu, Nepal

Experience Points 1,225
Experience Level 1

3,775 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 7
Lessons
Completed
Best Reply Awards 0
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.

19 Mar
3 years ago

aspiresuvedi left a reply on Error On Overriding ConfigureLogging Bootstrap Class

Actually , what I did above was all correct and I need to do additional interface binding for ConfigureLogging class in bootstrap/app.php which would otherwise fail on composer update

$app->singleton(
    'Illuminate\Foundation\Bootstrap\ConfigureLogging',
    'App\Bootstrap\ConfigureLogging'
);

also I changed the log key on config/app.php to custom and it worked.

12 Mar
3 years ago

aspiresuvedi started a new conversation Error On Overriding ConfigureLogging Bootstrap Class

While trying to implement logentries on L5, I tried to override ConfigureLogging class. Firstly , I override the $bootstrappers property of HttpKernel in Kernel class. using

protected $bootstrappers = [
        'App\Bootstrap\ConfigureLogging',
        'Illuminate\Foundation\Bootstrap\DetectEnvironment',
        'Illuminate\Foundation\Bootstrap\LoadConfiguration',
        'Illuminate\Foundation\Bootstrap\HandleExceptions',
        'Illuminate\Foundation\Bootstrap\RegisterFacades',
        'Illuminate\Foundation\Bootstrap\RegisterProviders',
        'Illuminate\Foundation\Bootstrap\BootProviders',
    ];

My App\Bootstrap\Configure class to implement logentries looks like

<?php namespace App\Bootstrap;

use Illuminate\Log\Writer;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as BaseConfigureLogging;
use Monolog\Handler\LogEntriesHandler;

class ConfigureLogging extends BaseConfigureLogging {

    /**
     * Custom Monolog handler that for Logentries.
     *
     * @param  \Illuminate\Contracts\Foundation\Application  $app
     * @param  \Illuminate\Log\Writer  $log
     * @return void
     */
    protected function configureCustomHandler(Application $app, Writer $log)
    {
        $logentriesHandler = new LogEntriesHandler(getenv('LOGENTRIES_TOKEN'));
        $log->getMonolog()->pushHandler($logentriesHandler);
        // Also Log to Dayily files too.
        $log->useDailyFiles($app->storagePath().'/logs/laravel.log', 5);
    }

}

But it throws error like this

Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist' in /var/www/agentcis/vendor/laravel/framework/src/Illuminate/Container/Container.php

10 Mar
3 years ago

aspiresuvedi left a reply on Mocking And Testing With Eqlouent Inside

Facing similar problem , share me if you have found any solution

BadMethodCallException: Method Mockery_1_App_Agentcis_Entities_Client_Client::getAttribute() does not exist on this mock object

09 Mar
3 years ago

aspiresuvedi started a new conversation Tests File Uploads Using Phpunit And Mockery

I am newbie to phpunit tests. I need to write tests to a service class Uploader which has following functions

public function saveClientDocument($client, $documents, $inputs)
    {
        foreach ($documents as $document) {
            $pathName = $this->generatePathName($document->getClientOriginalName());
            if ($this->moveDocument($document, $pathName)) {
                $data = [
                    'original_name' => $document->getClientOriginalName(),
                    'path_name'     => $pathName,
                    'document_type' => $inputs['document_type'],
                    'uploader'      => $this->auth->user()->id
                ];
                $this->saveDocument($client, $data);
            }
        }
        $this->logger->info(sprintf('%d documents uploaded for client %d', count($documents), $client->id));
        return true;
    }

    protected function moveDocument($document, $pathName)
    {
        try {
            $document->move($this->uploadPath, $pathName);
            return true;
        } catch (Exception $e) {
            $this->logger->error('Error on uploading document ', ['message' => $e->getMessage()]);
            return false;
        }
    }

    protected function saveDocument($client, $data)
    {
        if (!$this->documentRepository->save($client, $data)) {
            $this->logger->error('Document is not saved.');
            return false;
        }
        return true;
    }

    protected function generatePathName($name)
    {
        return md5(microtime() . $name);
    }

I need to write tests for public function saveClientDocument()

I am confused about calling the protected functions which is called inside the public functions and also confused about using mockery of file uploads and logger ? Any help to write tests for the public function would really be appreciated. :)

18 Feb
4 years ago

aspiresuvedi left a reply on Any Links To Read Or Watch For ACL?

** Zicaco Entrust **is one the best package for roles and permission, check it once.

aspiresuvedi left a reply on Problem With Authentication In Laravel 5

did you have used use AuthenticatesAndRegistersUsers; trait ? Check it once!

05 Feb
4 years ago

aspiresuvedi started a new conversation Set Up Dynamic Database Connection Globally

I am starting on a Multi tenancy application and need to use separate schema for each tenant. Most of the threads on the forum and blogs mentioned on how to accomplish multi tenancy using single database. But I didn't find any good solutions to multiple database. I ended up it solving on my own , dont know the correct way. Here's how tried to accomplish

$tenant = Tenant::whereSubDomain($subdomain)->first();              Config::set('database.connections.mysql.database', $tenant->db_name);       
Config::set('database.connections.mysql.username',$tenant->db_username);
Config::set('database.connections.mysql.password',$tenant->db_password);

dd(\DB::connection('mysql'));

It dumps the old mysql credentials, not the one I override with Config::set(...)

I need this database connection globally on the application for that request. such that I can use

$user = TenantUser::first();

instead of $users = DB::connection('mysql')->select(...);

Is there any way I can solve this problem.

29 Jan
4 years ago

aspiresuvedi started a new conversation Search All The Columns Using Laravel Query Builder

This is much of a mysql related question. But I need to solve it in a laravel way. I have to implement a search functionality which makes search on every column of the table and join table. I have used postgres as database and query needs to be perfomed in json column type also.

My query like this

$cases = \DB::table('cases')
            ->join('services', 'cases.id', '=', 'services.case_id')
            ->where(function($query) use ($request)
            {
                $query->whereRaw('*', 'like', '%'.$request->get('query').'%');
            })
            ->get();

I need to perfom where query to all columns.

09 Jan
4 years ago

aspiresuvedi started a new conversation Mime Type Validation Not Working For All Mime Types

When I try to validate files using

mimes:jpeg,png,pdf,csv|max:5000

validation only worked for jpg, png and pdf but not for csv , when i dumped the csv file using dd($file->getMimeType() ) It showed mime type to be 'text/plain'

then I added the same to the mimes validation list as

mimes:jpeg,png,pdf,csv,text/plain|max:5000

It still doesn't validate. P.S, mimes on config/mimes.php dont work.

07 Jan
4 years ago

aspiresuvedi left a reply on Laravel Suppor For Postgres On Eloquent

@Gufran I will surely post it on Github. I have posted here because there are laravel geeks active in this forum too ;) . I guess adding postgress specific traits could solve the problem. We could use those traits only for the models we need postgres support and similar for database migration , adding Postgres specfic traits on migration class could also solve the problem.

aspiresuvedi left a reply on Laravel Suppor For Postgres On Eloquent

Yeah it supports for postgres but I am here talking about is postgres data type like json or array . Wouldn't it be cool if we could create database migration for column of type json and make a query using json key on eloquent model....

aspiresuvedi started a new conversation Laravel Suppor For Postgres On Eloquent

When we have to deal for postgres data type like json or array , It is difficult to create schema migration and make query on json using json key. If Eloquent would add the support postgres it would be really awesome

05 Jan
4 years ago

aspiresuvedi left a reply on Laravel 5 Form Builder

I have been using this form for my project . Its great but sometimes when I need more configurations options I find it difficult to enhance .

aspiresuvedi left a reply on Redirect Not Working On All Methods

Thanks @pmall to make it clear. So does that mean that we can only send Http response only from those methods which have been called through routes . @bestmomo I also use form requests for form validation but i encountered problem for multiple file validations.

aspiresuvedi left a reply on Redirect Not Working On All Methods

I also use Form Request for form validation and I encountered problem for multiple file validations and the issue I have actually is that

aspiresuvedi left a reply on Redirect Not Working On All Methods

I am sorry, my question was not presented what i intended to ask. I have modified the question , I actually don't understand is that why the return redirect()->back() doesn't redirect anyway from the fileValidation method.

aspiresuvedi left a reply on Redirect Not Working On All Methods

This is just a sample code , The main problem is that that return redirect()->back() is not fired for the fileValidation method

aspiresuvedi started a new conversation Redirect Not Working On All Methods

I have encountered with a weird problem while working with redirects in laravel 5. the same redirect doesn't work for all methods. public function store( ){ $this->fileValidation(|nput:all()); return redirect()->back(); .. .. } public function fileValidation($inputs){ return redirect()->back(); } In these two methods the redirect only works for the store method but not for fileValidation . Any help would be appreciated.

29 Dec
4 years ago

aspiresuvedi started a new conversation Deploy Laravel 5 Application On Production Server With Apache

I have a working laravel 5 application with built in php server. But I encounter problem while deploying on a apache server. I have put this in .htaccess of project's root directory RewriteEngine On RewriteRule ^(.*)$ public/$1 [L]

and this in .htaccess of public directory Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

When I run http://localhost/myapp/ it shows blank page. Am I supposed do any other configurations for this to work ?

17 Dec
4 years ago

aspiresuvedi started a new conversation Add Migration Option Data Type Like Json , Array For Postgres Db

There is no feature for adding json or array data type and support for other data types for postgres in laravel migration. It would be a great if laravel had this feature.