tisuchi

Member Since 4 Years Ago

Kuala Lumpur

Software Engineer at Avana

Experience Points 388,805
Experience Level 50

0 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 1474
Lessons
Completed
Best Reply Awards 239
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.

18 May
1 day ago

tisuchi left a reply on Laravel Str_slug Not Working For Unicode.

str_slug or facade version Str::slug doesn't work with non-ascii string. You can instead use this approach

Check this solution: https://stackoverflow.com/questions/38800581/laravel-str-slug-not-working-for-unicode-bangla

tisuchi left a reply on Nested Loop In Laravel Blade

@DARRENCHAN - In this case, you can easily use relationship here.

@foreach ($users as $user)
    @foreach ($user->friends as $friend)
        // Now I want to check if like this way.
        @if ($friend->id == $friend->user->id)
            
        @endif
    @endforeach
@endforeach

I just use user relationship form the friend model here. Try this.

tisuchi left a reply on Form Request Validation Redirect

What do you mean by control? What exactly you want to do after request validation?

tisuchi left a reply on Login Via User Id.

If I get you correctly, you are looking for something like this.

Auth::loginUsingId(1);

Here, 1 is the userId.

Even you can use remember me option there too.

// Login and "remember" the given user...
Auth::loginUsingId(1, true);

https://laravel.com/docs/5.8/authentication#authenticating-users

tisuchi left a reply on Nested Loop In Laravel Blade

Have you tried with $loop->parent? Normally it returns the parent loop data.

https://laravel.com/docs/5.8/blade#control-structures

16 May
3 days ago

tisuchi left a reply on How To Retrieve Env Variable?

@JLRDW - I think env() used for Environment Configuration variables. Isn't that?

Ref: https://laravel.com/docs/5.8/configuration#environment-configuration

tisuchi left a reply on How To Retrieve Env Variable?

Have you tried this way in your controller?

echo env('MY_APP_URL');

This line should print out http://127.0.0.1:8000 anywhere (controller / models / view) in your application

tisuchi left a reply on Where Do Laravel Store All The Configuration Files?

Normally it stores in config directory.

All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

Ref: https://laravel.com/docs/5.8/configuration

15 May
4 days ago

tisuchi left a reply on Making A Route Public For Anyone To View

@AP3TWE - In that case, you can make an auth middleware in your route. No need to use __construct() .

tisuchi left a reply on How To Store Multiple Selection Data?

@HASANDEV - yeap.

And make sure, the model has fillable properties in the field.

tisuchi left a reply on Making A Route Public For Anyone To View

The route seems public already. Make sure, there is no authentication checking in the __construct() method in your ProjectsController.

tisuchi left a reply on How To Store Multiple Selection Data?

I have a route idea like this way-

In your view, form selection should be like this-

<select name="countries[]" multiple="multiple">
    ...

Now in your method in the controller, you should insert like this-

$countries = $request->input('countries');

foreach($countries as $country){
    UserCountry::create([
        'country_id' => $country,
        'user_id' => Auth::id()
    ]);
}

Hope it will work for you.

tisuchi left a reply on Undefined Index

@PAULCATALIN97 - I haven't noticed that you have received data from the user in the wrong way. It should be like that. Can you try with this code in your controller?

$skills = $request->input('skills');

        foreach($skills as $skill){
            Joburi::create([
                'titlu' => $request->input('titlu'),
                'descriere' => $request->input('descriere'),
                'salariu_estimativ' => $request->input('salariu_estimativ'),
                'oras' => $request->input('oras'),
                'id_skill'=>$skill,
            ]);
        }

tisuchi left a reply on Undefined Index

@paulcatalin97

I just update your whole code here...

<div class="dropdown-field">
    <select data-placeholder="Selecteaza Specializare" class="chosen" id="skills" name="skills[]" multiple="multiple">
        @foreach($skills as $skill)
            <option value="{{$skill->id}}" >{{strtoupper($skill->name)}}</option>
        @endforeach
    </select>
<div class="box-footer">

Here is the controller-

class AdaugaJobController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $skills = SkillsEmployee::all();
        return view('adaugajob', compact('skills'));
    }

    public function store(Request $request)
    {
        $data = $request->validate([
            'titlu' => 'required|string|max:255',
            'descriere' => 'required|string|max:255',
            'salariu_estimativ' => 'required|string|max:255',
            'oras'=> 'required',
            'id_skill'=>'',

        ]);

        $skills = $data['skills'];

        foreach($skills as $skill){
            Joburi::create([
                'titlu' => $data['titlu'],
                'descriere' => $data['descriere'],
                'salariu_estimativ' => $data['salariu_estimativ'],
                'oras' => $data['oras'],
                'id_skill'=>$skill,
            ]);
        }
        if($data){
            return redirect()->route('adaugajob')->withSuccess('S-a incarcat cu success!');
        }else{
            return redirect()->route('adaugajob')->withDanger('Nu s-a incarcat! A aparut o eroare.');
        }
        }
    }

I think it should work.

tisuchi left a reply on Undefined Index

@PAULCATALIN97 - This is the wrong way. It should be like this-

 $skills = $data['skills'];

tisuchi left a reply on Undefined Index

@PAULCATALIN97 - What exact error you are facing?

tisuchi left a reply on Undefined Index

@PAULCATALIN97 - It depends on what you want. If you want to allow the user to choose more than one skill at a time, then you need to do like that way.

I have updated my answer. Check this.

tisuchi left a reply on Undefined Index

I think it needs to be an array name="skills[]".

<select data-placeholder="Selecteaza Specializare" class="chosen" id="skills" name="skills[]" multiple="multiple">

tisuchi left a reply on Why My Update Is Not Working?

There could be few possibilities.

The first things in my mind that, you have to make sure you have fillable properties in your post model. It should be like that-

Post extends Model{
    
    protected $fillable = ['title', 'details'];


    ...

}

tisuchi left a reply on How To Create Unique Slug In Laravel?

There are lots of resources on that.

You can follow this tutorial-

Or you can even use a package for that. https://github.com/spatie/laravel-sluggable

and google it, you will get more..

14 May
5 days ago

tisuchi left a reply on How To Redirect If User Is Not Authenticated?

@DEVFREY - Yeah.. True. Thanks man. :)

@darrenchan you can add this suggestion in your list too...

tisuchi left a reply on How To Redirect If User Is Not Authenticated?

You can use auth middleware in your route.

tisuchi left a reply on Why I Am Getting Error?

@VAN1310 - Actually, both are the same.

echo "Welcome " . Auth::user()->name;

and

$user=Auth::user();
echo "Welcome" . $user->name;

tisuchi left a reply on Why I Am Getting Error?

You need to make sure that, requested user is logged in.

Change your code like this way-

if(Auth::check()){
    echo "Welcome " . Auth::user()->name;
}

tisuchi left a reply on Trying To Get Property 'id' Of Non-object

Make sure, the requested user is logged in.

Otherwise, you can wrap your code like this way-

public function __construct()
{
    if(Auth::check()){
        this->currentuser = Auth::user()->id;
    }
}

tisuchi left a reply on Routes - Weird Behaviour

@GIORG - Ofcourse you can use get.

The post is an example only.

Have you tried by manipulating like this way?

<form method="get">
    <input type="hidden" name="_method" value="patch">


tisuchi left a reply on Routes - Weird Behaviour

It's because the browser cannot detect PATCH method.

You need to use GET or POST but in your form, you can use a hidden field that contains method request.

<form method="post">
    <input type="hidden" name="_method" value="put">
   Etc.. 
</form>

tisuchi started a new conversation Unnecessary Posts.

Hello @jeffreyway

Over the last 1 hour, there are few unnecessary posts in a different language that is neither relevant nor readable.

You need to take care of such kind of spamming...

@jeffreyWay

tisuchi left a reply on PHP Carbon Not Working As Expected.

Normally you need to define new column in your model.

For example-

ModelName extends Model{
    public $timestamps = ['brithday'];

    ...

tisuchi left a reply on Expected Status Code 422 But Received 500

Since it's 500 error, you can get error details in storage/logs/laravel.log file.

The log file might be looks like this ../laravel-2019-05-14.log also.

You will get more details there.

tisuchi left a reply on How To Use Event And Listener?

@HASANDEV - Then pay for premium membership.. lol

Of course, Jeffrey made some good content for paid user. That is fair enough.

However, if you can check the youtube video also beside official documentation, where both of them explain event and listener clearly. I hope you can understand that.

tisuchi left a reply on How To Use Event And Listener?

Hi,

I personally suggest you read the documentation first. https://laravel.com/docs/5.8/events

There is a video from Jefreey. https://laracasts.com/series/how-do-i/episodes/4

If you looking for more details of understanding Event and Listener, watch this video. https://www.youtube.com/watch?v=e40_eal2DmM

13 May
6 days ago

tisuchi left a reply on Validation: Sometimes|Required

@FUNDI - How about your database filed structure? Does this field allow nullable? Make sure that allow nullable.

tisuchi left a reply on Count Distinct Children Within Relationship

First of all, in the event table, session_id filed is missing. You have forgotten to add that.

Now, you have a few options to figure it out.

  1. Using relationship. In that case, you can pass an anonymous method in eager loading then do filtration.

  2. In your relationship, you can define more logic. For example-

public function events()
{
        return $this->hasMany('App\event','session_id', 'id')->where('put your logic here')->where('Add more logic');
}
  1. Maybe you can apply Laravel query scope. Read more: https://laravel.com/docs/5.8/eloquent#query-scopes

tisuchi left a reply on Validation: Sometimes|Required

Does it trigger any error? You may print out validation error details to check what's required there?

tisuchi left a reply on Expected Status Code 200 But Received 201.

@HJORTUR17 - hmm... I think he used unconsciously. It should be 201.

tisuchi left a reply on Expected Status Code 200 But Received 201.

Normally the status code of creating a record is *201. However, you are expecting **200** instead of *201.

Here is the code-

$this->post($thread->path().'/athugasemdir', $reply->toArray())
            ->assertStatus(200);

Here, assert status code should beassertStatus(201) since it's posting something.

tisuchi left a reply on ToArray(), WhereMonth(), WhereYear() Deprecated?

Still, you can use whereMonth() and whereYear() in the Database Query.

https://laravel.com/docs/5.8/queries

tisuchi left a reply on How To Update Multi Data Into Database

What problem you are encountering now?

11 May
1 week ago

tisuchi left a reply on BelongsToMany With 4 Tables

I think you can define your relationship like this ways.

  • A users has many user_has_schools.
  • A user_has_schools belongs to a schools.
  • A user_has_schools belongs to a roles.

Once successfully define the relationship, you can easily access schools and roles from the user model easily by following Nested Eager Loading rules.

Ref: https://laravel.com/docs/5.2/eloquent-relationships#eager-loading

tisuchi left a reply on PHP Pinterest Integration.

Have you checked this? https://github.com/seregazhuk/php-pinterest-bot

Recently I have used this. I feel it's one of the best packages for PHP until now.

07 May
1 week ago

tisuchi left a reply on Model::create($data) With Carbon Dates Fields In $data Returns Carbon Object.

@AMITSHAHC - Can you show your real code? How do you store start_time?

tisuchi left a reply on How To Show Message (MOTD) On All Pages?

There are a few ways to do that. I think this tutorial will be easy for you to understand.

https://itsolutionstuff.com/post/laravel-5-implement-flash-messages-with-exampleexample.html

tisuchi left a reply on Model::create($data) With Carbon Dates Fields In $data Returns Carbon Object.

By default, the model makes Carbon instance created_at and updated_at.

However, if you need to make carbon instance of any field, i.e. start_time you need to define in your model.

Just add this in your model.

 protected $dates = [
        'start_time',
    ];

Hope, it won't act differently now.

tisuchi left a reply on The PUT Method Is Not Supported For This Route. Supported Methods: GET, HEAD, POST.

@MUAZZAMAZAZ - Just explaining @foram idea a bit.

You just add PUT hidden field after declaring form tag like this-

{!! Form::model($destination, array('action' => array('[email protected]', $destination->id),'enctype'=>'multipart/form-data', 'method' => 'POST')) !!}

<input type="hidden" name="_method" value="PUT">

.
.
.

tisuchi left a reply on Can't Login To Admin Section On Server

I suggest you just understand the concept first. Here are some resources how to define relationships.

Hope it will help you to increase your skills.