SinghWithLaravel

SinghWithLaravel

Member Since 5 Months Ago

Experience Points
5,350
Total
Experience

4,650 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
15
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 2
5,350 XP
Mar
19
2 months ago
Activity icon

Replied to How To Add A Specific Key In Each API Response.

@tykus Yup, i want to add it in payload . I am not using Laravel Resource.

Activity icon

Started a new Conversation How To Add A Specific Key In Each API Response.

I want to add a specific key in each API reponse in Laravel. How can i do that ?

Mar
06
2 months ago
Activity icon

Replied to Cannot Modify Header Information.

@verbose Did the soution worked for you ?

Mar
03
2 months ago
Activity icon

Replied to Laravel Developer Remote Jobs

@tisuchi I am going with it. let's see, how long does it takes!

Activity icon

Started a new Conversation Laravel Developer Remote Jobs

Do Anyone have any references for Laravel Developer Remote Jobs ? I would love to work on Laravel.

Activity icon

Started a new Conversation Laravel Developer Remote Jobs

Do Anyone have any references for Laravel Developer Remote Jobs ? I would love to work on Laravel.

Feb
27
3 months ago
Activity icon

Replied to Laravel 6+ Upload Multiple Images Through A Form

@seeker1337 Change $allImages = explode("|",$vehimages); like below line -

$allImages = explode("|",$VehiclesModel->vehimages);

Activity icon

Replied to Laravel 6+ Upload Multiple Images Through A Form

@seeker1337 Yeah, you can loop through the images. In that case you will have to explode it from comma like below code. -

<?php   

    foreach ($vehiclesmodel as $VehiclesModel) {
    $allImages = explode("|",$images);

?>    
    
<tr> 

    <td> {{ $VehiclesModel->id }} </td>
    <td> {{ $VehiclesModel->vehmod }} </td>
    <td> {{ $VehiclesModel->vehmark }} </td>
    <td> {{ $VehiclesModel->vehyear }} </td>
    <td> {{ $VehiclesModel->vehengine }} </td>
    <td> {{ $VehiclesModel->vehtrans }} </td>
    <td> 
    @php
        @foreach($allImages as $image)
                <img src="storage/veh-images/{{$image}}" height="50px" width="30%">
        @endforeach
    @endphp
    </td>
 
</tr>
 
<?php  }    ?>
Feb
20
3 months ago
Activity icon

Replied to I Want To Validate Route Parameter To Be One Of The Two Given Values, How Can I Do It ?

@sinnbeck I simply did it like this -

    Route::post('InspectionChecks/List/{type}', '[email protected]')->where('type',"ASSET|TRAILER");

What will regex will do here ?

Activity icon

Started a new Conversation I Want To Validate Route Parameter To Be One Of The Two Given Values, How Can I Do It ?

route::post('InspectionChecks/List/{type}', '[email protected]');

In above route, i want type to be either ASSETor TRAILER. How can we achieve it without going to the controller ?

Feb
18
3 months ago
Activity icon

Replied to [BUG REPORT] Laracasts Website

@JefferWay design problems are there.

Feb
17
3 months ago
Activity icon

Replied to Nested Relationship With GroupBy And Count

@maan56 Can't be done through relationship.

Activity icon

Replied to How Can I Run Database Migration On AWS Server Without Terminal Access ?

@hmazter It is an EC instance and using FTP for deployment.

Feb
16
3 months ago
Feb
14
3 months ago
Activity icon

Started a new Conversation How Can I Run Database Migration On AWS Server Without Terminal Access ?

Is there some other way to run migration on AWS server without using terminal access of the server ? can we do that using Artisan class like below -

Artisan::call('migrate --path=database/migrations/2020_02_13_124322_alter_tablelist.php');

I tried above command, but it didn't work.

Feb
12
3 months ago
Activity icon

Replied to How Can I Delete Data In Larvel Relation, When We Have Nested Relations ?

@sti3bas What if I Use delete() rather than destroy() ? Through, right now i am passing single id. So it is good to go for now.

Activity icon

Replied to How Can I Delete Data In Larvel Relation, When We Have Nested Relations ?

@sti3bas I don't think just to solve this problem, I should use package. I just got a solution, check it out below -

        $object=Corporation::find($id)
        ->load([
                'regions',
                'regions.districts',
                'regions.districts.locations',
        ])
        ->destroy($id);

it will delete all nested relational data and for stored documents i will prefer using your delete event.

Do you think it is a good way ?

Activity icon

Replied to How Can I Delete Data In Larvel Relation, When We Have Nested Relations ?

@sti3bas What if i have relations inside Documents as well ?

Will it be easier if i don't delete documents while deleting records ?

Activity icon

Replied to How Can I Delete Data In Larvel Relation, When We Have Nested Relations ?

@sti3bas @tohby cascade delete will work only in Hard Delete(deleting from database) while I am gonna use Soft Delete. I need solution in case of Soft Delete.

@sti3bas yeah, Deleteing documents is also an issue.

Activity icon

Started a new Conversation How Can I Delete Data In Larvel Relation, When We Have Nested Relations ?

I want to delete nested data with parent data in laravel relation. Default way of laravel hust provides one way, and that is defined below -

User::find($id)->profile()->delete();

I want to delete all documents related to the user while its deletion. I don't wanna use events, neither loops or cascade delete. I want something builtIn. Is it possible ?

Activity icon

Replied to Is It Required To Make Relation Functions In Both Models While We Just Wanna Use One Model.

@alanholmes One more thing, i want to implement soft delete in Models, so how can I check whether a specific id exists in relation or not ?

Activity icon

Started a new Conversation Is It Required To Make Relation Functions In Both Models While We Just Wanna Use One Model.

Basically i am having two models Comments and Posts.

(1) First Part - I have to access comments of a single post. For that i can make a hasMany relation function like below.

    public function comments()
    {
        return $this->hasMany('App\Comment');
    }

While accessing, i will simply call this function with post model's instance.

(2) Second Part - Is it enough to use above relation to access comments of specific post or i need to use below relation as well. In some web pages I read that I will need to define relation function in Comments model as well.

    public function post()
    {
        return $this->belongsTo('App\Post');
    }

I think First Part is enough to get all the comments related to a post. Second part is only needed if i need to fetch the post for a specific comment, right ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 You can make one of the answers as Best, if you think it is.

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 Check database, whether that is following the migration or not ? Whether that is having defined enums, default value as per code or not ?

Feb
11
3 months ago
Activity icon

Started a new Conversation How To Get Soft Deleted Records From Eager Loading And Lazy Eager Loading ?

I want get deleted records eager & lazy eager loading relations. How can i achieve that ? I found some solutions on stackoverflow, which have been written below -

  1. use withTrashed() method wih relation function like below -
     public function deletedVideos() {
           return $this->hasMany(Video::class, 'deleted_by_user_id')
            ->withTrashed();
          }
        
    
  2. Use withTrashed() with after relation while calling like below -
Model::find($id)->post()->withTrashed()->get();

I want to know the solution in case, if i have many relations, what can i do ? have a look at below situation -

$assetDetails = $assetDetails->with(['assetDocuments' => function ($query) {
$query->select('id', 'assetId','assetUsage','volume','amount', 'documentType', 'links', 'link','userId', 'uploadTime', 'expiryDate','coordinate')
->orderBy('assetdocument.uploadTime', 'desc')
->get();
},'assetDocuments.userDetails:id,firstName,lastName,middleName']);
$assetDetails = $assetDetails->with(['safetyCheckListSaveInfo' => function ($query){
$query->select('id', 'assetId', 'userId', 'type','checks' , 'coordinate', 'created_at','created_at')->orderBy('created_at', 'desc');
},
'safetyCheckListSaveInfo.userDetails:id,firstName,middleName,lastName']);

How can i use soft delete with bunch of realtions ?

Activity icon

Replied to Dompdf Page Break Issue

@ajithlal @shing_shing This is still a unresolved issue dear, we are working on it.

Activity icon

Replied to How To Display HSN Code Wise Data In Laravel Using Table Format

@krishma You can use below code -

$data = Yourmodel::groupBy('hs_code')
->get();

By the above code you will get the list of grouped HSC codes. But for total, you will have to do that through you php code.

If you don't wanna get that from php code, you can hit one more query for it like below -

$data = Yourmodel::selectRaw('sum(amount)')
->groupBy('hs_code')
->get();
Activity icon

Replied to Ajax Crud

@gregers Do you want to use Sentinel as an RESTful API ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 It might be happening due to case difference in enum definition & update value. Make sure they are same.

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 Can you post your enum values here, which you have set in database and migration ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 Can you put your enum values here ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 What is the default value which is getting saved while updating ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 What is the default value which is getting saved while updating ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 if you will not set anything anything while updating, it will update value to default.

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 Are you getting value in below fields -

$request->religious
$request->caste

Firstly make sure they are getting values or not, keep cache cleared ever.

And why are you using ?? in code ? Are you trying to use ternery operator ?

Activity icon

Replied to Store Or Update Enum Value

@kkhicher1 Which field is having enum value ?

Activity icon

Replied to How To Display HSN Code Wise Data In Laravel Using Table Format

@krishma If i am not wrong karishma, you want to group data on the basis of HSN code & show the sum of the amount for specific HSN code. For that you can simply use groupBy() data and select the sum of data here.

Feb
06
3 months ago
Activity icon

Replied to Not Able To Get ENV Variable Value In Laravel Controller.

@snapey I am checking in Controller function.

Activity icon

Started a new Conversation How To Write SubQuery In Laravel 5.8 ?

I want to write subquery in laravel 5.8, what are the ways and which one is best ? I need to convert below query into laravel query. -

SELECT "assetId",id,
    (
        SELECT recording.usage from recording where recording."assetId"=asset.id ORDER BY id DESC LIMIT 1
    )
FROM asset; 
Activity icon

Replied to Not Able To Get ENV Variable Value In Laravel Controller.

@bugsysha @sinnbeck , i tried with below code, but it didn't work.

config('mail.driver');
Feb
05
3 months ago
Activity icon

Started a new Conversation Not Able To Get ENV Variable Value In Laravel Controller.

I am not able to get ENV variables value in laravel controller. I have tried below two ways. -

env('MAIL_DRIVER');

And

$_ENV // array
Activity icon

Replied to Amazon S3 Upload ACL

As per the question, we can simply give permissions while uploading image, while we can do the same using bucket policy as well. Below code will make uploaded file as publicily readable.

$path = Storage::putFile('avatars', $request->file('avatar'), 'public');

That't it.

Jan
31
3 months ago
Activity icon

Replied to Socialite/Facebook Adding To Database

@zabarah As you said you have an relationship between Adaccount & User model, so we proceed ahead with it. You have to simply use create() method after your relationship method as below : -

// firstly you will have to fetch data from $user->getAdAccounts() method, and put that into $data array as per your keys in Adaccount model.
$data=[
'key'=>'value'
...
];
$createdInstanace=$newUser->adAccounts()->create($data);

It will save data into Adaccount model and will return you an saved instance of model.

Jan
30
3 months ago
Activity icon

Replied to Change Date Timezone In Laravel Project While Fetching Date.

@skauk This was the only solution for my case. Don't you think so ? I had to use accessor in each model to change date.

Jan
29
3 months ago
Activity icon

Replied to How Can I Write Accessor For Created_at Or Updated_at ?

@sinnbeck Yes i firstly set it to false. It needs to be true to get this accessor work.

Activity icon

Awarded Best Reply on Change Date Timezone In Laravel Project While Fetching Date.

@ahkeravi The problem was in snakeCase attribute.

public static $snakeAttributes = false;

If it is false you will need to append array of snake cased columns like below.-

    protected $appends = ['created_at','updated_at'];

If you make $snakeAttributes=true, it will work usually.