psylogic

psylogic

Member Since 1 Year Ago

Experience Points
26,660
Total
Experience

3,340 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
199
Lessons
Completed
Best Reply Awards
10
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 6
26,660 XP
Jun
20
3 weeks ago
Activity icon

Replied to Laracasts Series Subscribe Removed?

Sorry!

Yes, I think it is removed, and you have to check back often for updates.

that what it says at the bottom of the new series.

Activity icon

Replied to Condional Nova Actions

Well, in some cases it's okay to do that.. but for user experience, I don't want the user to click on something and respond back "Whoops action is not allowed".

I don't know why canSee() function doesn't have a resource as a second param, while canRun() does.

I don't know how to hide an action and display the other.

Activity icon

Started a new Conversation Condional Nova Actions

Hello,

I have some actions on table row, but I need to display actions in condition.

I tried to use canSee()

(new SetThingInProgress())
                ->showOnTableRow()
                ->canSee(function ($req) {
                    return $this->resource->status == Thing::PENDING;
                }),

Well, $this->resource it returns only the Model like just an instance, so $this->resource->status it obviously returns NULL. so canSee() is not working for me.

If I want to access to the property resource I have to use canRun() which accepts two params (NovaRequest, Model)

(new SetThingInProgress())
                ->showOnTableRow()
                ->canRun(function ($req, Thing $thing) {
                    return $thing->status == Thing::PENDING;
                }),

But that will help just users to run this action in condition.

Any suggestion please, maybe I missed something in the doc.

Jun
19
3 weeks ago
Activity icon

Awarded Best Reply on Sending Multiple Email Product Suppliers When Order Is Placed

Well, buddy, your approach is good and of course, you need to make it queueable for better user experience. and another thing is you need to loop over all suppliers' email or you can send them as CCor BCC array if you don't want to loop.

Looping:

foreach($event->suppliers as $supp){
   Mail::to($supp->email)->send(new Thing());
}

or


Mail::to("[email protected]")->cc($event->suppliers->pluck('email')->toArray())->send(new Thing());

Well you get the point..

Activity icon

Replied to How To Query Result Form Given Time Range With MYSQL

I recommend you to use https://carbon.nesbot.com/docs will helps you to cast the date and time as you want.

Activity icon

Replied to Ignore Error From Mail Method

as @michaloravec replied, using a checker is better than wrapping with try-catch block.

Well, that will save your quota (if you're using a service) and avoiding bounces that leads to low your IP reputation.

Activity icon

Replied to Sending Multiple Email Product Suppliers When Order Is Placed

Well, buddy, your approach is good and of course, you need to make it queueable for better user experience. and another thing is you need to loop over all suppliers' email or you can send them as CCor BCC array if you don't want to loop.

Looping:

foreach($event->suppliers as $supp){
   Mail::to($supp->email)->send(new Thing());
}

or


Mail::to("[email protected]")->cc($event->suppliers->pluck('email')->toArray())->send(new Thing());

Well you get the point..

Activity icon

Replied to Search Results To Collection Resource

What do you mean by is not working?

Apr
23
2 months ago
Activity icon

Replied to One To Many With Pivot Not Possible. How To Redesign Relationships?

Well, now your update is clear, and what about supplier has many delivery services, it will be more clear since supplier is dealing with many services.

so tables now are clear for you, mmm ? is it gonna work for you?

Activity icon

Replied to Laravel Validation DTO

Your Layer:


/**
	 * @param array $data
	 * @param User  $user
	 *
	 * @return mixed
	 */
	public function update(User $user, array $data)
	{
		$user->update($data);	
		return $user->fresh();
	}
	

Your Controller


/**
	 * @param UserRequest $request
	 * @param User        $user
	 *
	 * @return \Illuminate\Http\JsonResponse
	 * @throws \Throwable
	 */
	public function update( UserRequest $request, User $user )
	{
		$user = $this->userService->update($user,$request->validated());
		
		return response()->json($user, 202 );
		
	}

I think is simple

Activity icon

Replied to Do Something Before A Relationship Changes

What do you mean? please provide some snippets and more details.

Activity icon

Replied to Running Npm Install Using Laravel (Installing Vue)

Well, all packages of npm are installed into node_modules folder in your root Laravel folder.

and composer packages are installed into vendor folder

Activity icon

Replied to Complex Substitution In Blade ...

You can use the getters in your Model like so getAddressAttribute() and manipulate it as you like.

Activity icon

Replied to How Can I Send 'multipart/form-data' While Testing?

Testing on Postman , Insominia, web ?

Feb
14
4 months ago
Activity icon

Replied to Table Data Blade

@swimmer flex item or a css grid are the easiest way to do that.

or you can style it in your own like in this tuto

https://designmodo.com/shopping-cart-ui/

Activity icon

Replied to Security Question

When a file is declared public, you are indicating that the file should generally be accessible to others. For example, when using the S3 driver, you may retrieve URLs for public files.

Storage::put('file.jpg', $contents, 'public');

in your case your file is private, it will not be accessible to others.

Activity icon

Replied to Display Specific Values ​​in Relation

You question is not clear, please always provide your code, or example !

Feb
13
5 months ago
Activity icon

Replied to Alter Default Resource Delete Action

Do you mean adding deletet_at to table ? you can use soft delete !

Or anything else about deleting a resource you can refer to doc

https://laravel.com/docs/5.8/eloquent#deleting-models

but before that could you tell us more about what do you wanna achieve exactly ? some examples !

Activity icon

Awarded Best Reply on Save Multiple Checkboxes To The Database

User modal

I guess you will have hasMany(Coordenador::class)

by using this line laravel will automatically inject user_id with auth id into cordenator table

$data['q9'] = implode(",",$data['q9']);
auth()->user()->cordenator()->create($data);

or in the way you use

public function store(Request $request) {
        $data = $request->input();
        $data['user_id'] = Auth::id();
        $data['q9'] = implode(",",$data['q9']);
        Coordenador::create($data);
}

Activity icon

Replied to Save Multiple Checkboxes To The Database

User modal

I guess you will have hasMany(Coordenador::class)

by using this line laravel will automatically inject user_id with auth id into cordenator table

$data['q9'] = implode(",",$data['q9']);
auth()->user()->cordenator()->create($data);

or in the way you use

public function store(Request $request) {
        $data = $request->input();
        $data['user_id'] = Auth::id();
        $data['q9'] = implode(",",$data['q9']);
        Coordenador::create($data);
}

Activity icon

Replied to Save Multiple Checkboxes To The Database

if you have relation between Coordenador and User

you can use auth()->user()->cordenator()->save($data)

of course after using implode function on $request->q9

Activity icon

Replied to Laravel Auth Login Error

this is the stub code of login page; you may miss something

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Login') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('login') }}">
                        @csrf

                        <div class="form-group row">
                            <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>

                                @error('email')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">

                                @error('password')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-6 offset-md-4">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

                                    <label class="form-check-label" for="remember">
                                        {{ __('Remember Me') }}
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-8 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Login') }}
                                </button>

                                @if (Route::has('password.request'))
                                    <a class="btn btn-link" href="{{ route('password.request') }}">
                                        {{ __('Forgot Your Password?') }}
                                    </a>
                                @endif
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Activity icon

Replied to Save Multiple Checkboxes To The Database

Do you want to save the answers in same column as a string or json ? or each answer in new row ?

Activity icon

Replied to Validating User Input

@abc123

use gt:field validation

 'age2' => ['required', 'integer', 'max:100', 'gt:age1'],

for more informatoin about validation

https://laravel.com/docs/5.8/validation#available-validation-rules

Activity icon

Replied to Flattening With Collect Helper Changes Collection To Empty

$employees->values()->all() didn't gives you result !?

Activity icon

Replied to Compact(): Undefined Variable

use only compact('cellphone') instead of compact('cellphone', $cellphone)

Activity icon

Awarded Best Reply on Call To A Member Function Store() On String When Testing Uploads

@chris1981 ;

Here's my code and it pass and please check the status also the URL if it is correct

and you should pass the images as array

'filename' => [
      $image = UploadedFile::fake()->image('fakeimage.jpg')
      ]

api.php

Route::post('/upload', 'TestController');

Controller

public function __invoke(Request $request)
    {
        if ($request->hasFile('filename')) {
            foreach ($request->file('filename') as $image) {
                if ($upload = $image->store('images', 'public')) {
                    return  response()->json($upload, 201);
                }else{
                    return  response()->json("no", 403);
                }
            }
        }
    }

Test

public function testExample()
    {
        // to track the errors
        // $this->withoutExceptionHandling();


        Storage::fake('public');

        $this->postJson('/api/upload', [
            'filename' => [
                $image = UploadedFile::fake()->image('fakeimage.jpg')
                ]
        ])
        ->assertStatus(201);

        Storage::disk('public')->assertExists("images/".$image->hashName());
        Storage::disk('public')->assertMissing('images/missing.jpg');
    }
Activity icon

Replied to Call To A Member Function Store() On String When Testing Uploads

@chris1981 ;

Here's my code and it pass and please check the status also the URL if it is correct

and you should pass the images as array

'filename' => [
      $image = UploadedFile::fake()->image('fakeimage.jpg')
      ]

api.php

Route::post('/upload', 'TestController');

Controller

public function __invoke(Request $request)
    {
        if ($request->hasFile('filename')) {
            foreach ($request->file('filename') as $image) {
                if ($upload = $image->store('images', 'public')) {
                    return  response()->json($upload, 201);
                }else{
                    return  response()->json("no", 403);
                }
            }
        }
    }

Test

public function testExample()
    {
        // to track the errors
        // $this->withoutExceptionHandling();


        Storage::fake('public');

        $this->postJson('/api/upload', [
            'filename' => [
                $image = UploadedFile::fake()->image('fakeimage.jpg')
                ]
        ])
        ->assertStatus(201);

        Storage::disk('public')->assertExists("images/".$image->hashName());
        Storage::disk('public')->assertMissing('images/missing.jpg');
    }
Feb
12
5 months ago
Activity icon

Replied to Call To A Member Function Store() On String When Testing Uploads

would you try this one

$this->call('post','/api/upload', [],[],$photos);

using call instead of jsonPost

$photos = [
'filename' => [
    UploadedFile::fake()->image('fakeimage.jpg'),
    UploadedFile::fake()->image('fakeimage2.jpg')
  ]
];

$this->call('post','/api/upload', [],[],$photos);

Storage::disk('public')->assertExists("images/{$photos['filename'][0]->hashName()}");

Activity icon

Replied to Middleware: Add Value To $request?

if hopped from app to app , then you are already save the tracked data for this activated app. and with tabs is the same each app(tab) has its own session

Activity icon

Replied to Middleware: Add Value To $request?

Did you try to store it in session ?

Activity icon

Replied to Add , After Word But Skip The Last One

you can use computed property

computed:{
 separtedServices() { return this.checkedServiceTitles.map(service => service.description).join(', ') }
}
<span v-text="separtedServices"></span>
Activity icon

Awarded Best Reply on Laravel Validation Erro In Uploading JPG Image.

Great, would you mark the thread as solved. Thanks!

Activity icon

Replied to Laravel Validation Erro In Uploading JPG Image.

Great, would you mark the thread as solved. Thanks!

Activity icon

Replied to Sending Mail To Multiple Recipients With The “Name” Of Recipient In The Body

Yes, I think this is the only approach that is available right now.

Activity icon

Replied to Multi-tenancy Using Laravel App

@aqeel94321

https://github.com/PsyLogic/lara-tenancy

would you try this demo boilerplate. I used

"hyn/multi-tenant": "5.4.", "laravel/framework": "5.8."

you can clone and try your own , follow the readme

Activity icon

Awarded Best Reply on Database Help -> Join With Where!

where(Auth::user()->id, '=', 'carts.user_id')

first argument waiting column name not a value

use where('users.id', Auth::user()->id) instead

Activity icon

Replied to Database Help -> Join With Where!

where(Auth::user()->id, '=', 'carts.user_id')

first argument waiting column name not a value

use where('users.id', Auth::user()->id) instead

Activity icon

Replied to Sending Mail To Multiple Recipients With The “Name” Of Recipient In The Body

foreach($single as $sendTo)
{
    Mail::to($single['email'])->send(new EmailMessage($single['name']));
}

you can do it like that or get collection of users and pass object to EmailMessage

that first thought , but I'll look up for better idea

Activity icon

Replied to Laravel Validation Erro In Uploading JPG Image.

@felipesmendes ,

Would you try to increase the post_max_size from 2mb to 8mb because the Image jpg when it exceeded 2mb it become octet-stream (I could be wrong)

Try it and let me know !

Activity icon

Replied to Focus After Ajax Post

what if you did the focus inside setTimeout ?

Activity icon

Replied to Error Npm Run Production

Did you checked you app.scss file for any erros (Unclosed block,...)?

Activity icon

Replied to How To Search In Two Table Dynamically PHP ?

@ebrahemsamer ,

Do you mean if you don't find result in 1st table you will look in the 2nd table ?

Activity icon

Replied to Blade Auto-close Of Directives

@gvanto , Well new directives need to be added manually, but I think if there some config in the editor where you define the service provide that add your extra directives and editor will scan it and add them automatically

Activity icon

Replied to Deleting Wrong Data When We Press The Delete Button

@bhhussain ,

I think @snapey solution is working fine.

if not the case for you you can pass the genreated url to the function, like so:

<a href="javascript:;" data-toggle="modal" onclick="deleteData({{ route('admin.accounts.destroy', $c->id) }})" 
              data-target="#DeleteModal">


function deleteData(url)
   {
          $("#deleteForm").attr('action', url);
  }