Vilfago

Experience

31,940

41 Best Reply Awards

  • Member Since 2 Months Ago
  • 28 Lessons Completed
  • 1 Favorite

25th May, 2018

Vilfago left a reply on Auth::user() Not Refreshing After Update Using POST • 1 day ago

I tried to not querying again the db, but if the solution of @rin4ik is good for you, that's perfect.

Vilfago left a reply on Auth::user() Not Refreshing After Update Using POST • 1 day ago

$user = Auth::user();
$user->nickname = $request->nickname;
$status = $user->save();

dd(Auth::user());

Vilfago left a reply on How To Display 'value' From Database In An Article? • 1 day ago

Or maybe only using double quote, as the variables in them are interpreted by php ?

http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double

I don't know if it works, and you probably must use unescaped blade ({!! !!}), so you have to sanitize the content before storing it in the database.

Vilfago left a reply on Getting Data Range • 1 day ago

You want all workers, but only last contracts ?

What is the content of $today and $lastWeek ? (Carbon object, php datetime, ...)

Vilfago left a reply on How To Display 'value' From Database In An Article? • 2 days ago

I handled it this way :

  • store in db the article with in text something like "[statistic->female->count]"
  • when getting the article, use regex to replace the code with the current value.

Cons : I have a list of value to be replaced, and I can only use them. Pros : maybe a way to automatise the replacement ?

24th May, 2018

Vilfago left a reply on Getting All Objects If The Latest Status Is E.g. '100' • 2 days ago

If I understood well the request of @nizam0786 (after 4 threads here) :

His table "processes" receive a new entry each time the pass have a new status. For example :

  • Monday : id 1, pass_id 1, status 0;
  • Tuesday : id 1, pass_id 1, status 100;
  • Wedn. : id 1, pass_id 1, status 150;
  • Thursday : id 1, pass_id 1, status 200;
  • etc.

In this case (i.e for this thread, because the OP changed the status he request for at each thread), the pass_id 1 should not be retrieve, has it's not the last status (which is 200).

So I think he need a subquery to retrieve the status value of the last item in "processes" table to fill his where.

Vilfago left a reply on PDOException::("SQLSTATE[42S02]: Base Table Or View Not Found • 2 days ago

When you don't specify your table, Laravel try to get the plural form of the table. With the help of Inflector : https://github.com/doctrine/inflector/blob/master/lib/Doctrine/Common/Inflector/Inflector.php

And it has some rule (like "Child" -> "Children" and not "Childs"). And one of these is that word ending with "um" end with "a" at plural. Stadium -> Stadia Radium -> Radia etc.

So as @crisjohn02 tell you, add the attribute table to force the name of the table. It should work.

Vilfago left a reply on Can't Access Parent View's Variable In Child View. • 2 days ago

I just checked, and in fact on my side I use the data from viewComposer in my main template... so maybe it's standard behavior.

Maybe try :

public function compose(View $view)
    {
        View::share('totalCart', $this->totalCart);
    }

Vilfago left a reply on PDOException::("SQLSTATE[42S02]: Base Table Or View Not Found • 2 days ago

what is the value of $table in your Stadium Model ?

It should be "stadiums" as it's the name of your table, and it seems to be "sports_liga.stadia"

Vilfago left a reply on Can't Access Parent View's Variable In Child View. • 3 days ago

I guess in your composer you have :

View::composer('master', 'App\Http\ViewComposers\CartComposer');

It's more a workaround than a solution, but does it work if you do something like

View::composer(['master', 'home'], 'App\Http\ViewComposers\CartComposer');

?

Vilfago left a reply on Can't Access Parent View's Variable In Child View. • 3 days ago

I have no issue doing it.

What's your laravel version ? Can we see your view composer ?

Vilfago left a reply on Where Function In BelongsToMany Problem • 3 days ago

I don't know why it worked on your other site. Maybe lucky with your data type.

The purpose of with and load is to retrieve all relations data of your main query (or some relations data if you add a where clause as above). As you don't filter the main query, you will got all Node.

If you want to filter your main query with relation, you have to use has or whereHas : https://laravel.com/docs/5.6/eloquent-relationships#querying-relationship-existence

Vilfago left a reply on A Security Question • 3 days ago

Prepare a "white list" of all code that you accept, and sanitize anything else that these ones.

You can check them with regex.

23rd May, 2018

Vilfago left a reply on Where Function In BelongsToMany Problem • 3 days ago

$nodes=Node::with(['tags'=>function($query)use ($id){
            $query->where('tag_id','4');
        }])->paginate(12);

Vilfago left a reply on Change Value When Value Is Zero • 3 days ago

https://laravel.com/docs/5.6/eloquent-mutators#defining-a-mutator

public function setCreativeIdAttribute($value)
    {
        $this->attributes['creative_id'] = ($value == 0) ? 1 : $value;
    }

22nd May, 2018

Vilfago left a reply on Trying To Get Non Property Object When Looping Array • 4 days ago

I think the objective is to have a Collection object. If yes, toArray() is not a solution.

What do you get when you dd($temp); ?

21st May, 2018

Vilfago left a reply on Assign The Value Of Id In User Table To The User_id In Posts Table Automatically ?? • 5 days ago

@belykia What do you want more in your code ?

Vilfago left a reply on Keep User Data After User Is Deleted • 5 days ago

at the end of the handle method of VerifyEmail class. I never tried, but I don't see why it will not work.

Vilfago left a reply on Keep User Data After User Is Deleted • 5 days ago

With you queue workers, when he has sent his email, he can delete or create a new job to delete (permanent) the user.

Vilfago left a reply on Allow Only The User To See His CRUD Laravel 5.6?? • 5 days ago

Let's say that the data entered by the user from your form is stored in the table named datas.

Step 1 : add a user_id field in "datas" table to link the user with the data Step 2 : add the relation in both models (User and Data) Step 3 : when you saved data from the form to the database, add the information in the column user_id (with, by example Auth::id();) Step 4 : Retrieve the relevant data with your relation.

Vilfago left a reply on Eloquent's Eager Loading Returns Null • 6 days ago

The relation trying to match id with kd_barang. As it's not why you want, you have to clarify this in the relation.

//Product model
 public function transaction()
    {
        return $this->hasMany(Transaction::class, 'kd_barang', 'kd_barang');
    }

20th May, 2018

Vilfago left a reply on Store Data From Datatable With Selected ID • 6 days ago

and same with $request->user_id, I think your problem come from here.

Vilfago left a reply on Laravel Eloquent Triple Table Relation • 6 days ago

Ok. From my perspective, don't try to link all of that at once.

User have many team, set this relations User have many badges, set this one Team have many badges, set this one.

I don't think you will able to use " Has Many Through" due to the many to many relations, but you should be able to retrieve data in few request.

//Retrieve user badges:
User::with('badges')->get();

Vilfago left a reply on Laravel Eloquent Triple Table Relation • 6 days ago

If you have only one badge per user/team, I suggest this way: Tables: users teams badges (user_id, team_id, badge_number)

Use badges as pivot table between user and team, but create a model for the pivot table to retrieve badge easily as it seems critical fpr your application.

With the links given by @jlrdw and the following, you should be able to do it : https://laravel.com/docs/5.6/eloquent-relationships#many-to-many

Vilfago left a reply on Problem With Left Join • 6 days ago

You have to set the relation in your model before. https://laravel.com/docs/5.6/eloquent-relationships#introduction

Vilfago left a reply on Problem With Left Join • 6 days ago

Did you try $result = App\Rest::doesntHave('bookings')->get();

Vilfago left a reply on Problem With Left Join • 1 week ago

Vilfago left a reply on Problem With Left Join • 1 week ago

https://laravel.com/docs/5.6/queries#joins

$result = Rest::leftJoin('bookings', 'rest_id', '=', 'id')->where('rest_id', 'is', 'NULL')->get();

Vilfago left a reply on Not Working Button Delete Post At Laravel 5 • 1 week ago

@rumm.an was probably right. You probably have a clash but with edit route...

Vilfago left a reply on Updating HasMany Relationship • 1 week ago

I really don't understand why you store the phone number in luggage too...

Relational database are made you don't need (should) do that.

Vilfago left a reply on Don't Want Nested Queries • 1 week ago

What is the value of $filters ?

Vilfago left a reply on Not Working Button Delete Post At Laravel 5 • 1 week ago

<a href="{{ route('discuss.destroy' , $discuss -> id) }}"

If you show the source code in your webpage, what do you get.

And please explain what is not working... instead no one can help you

Vilfago left a reply on Not Working Button Delete Post At Laravel 5 • 1 week ago

It still doesn't answer, but I reply in the same way.

Route::get('/discuss/{id}', '[email protected]')->name('discuss.destroy');

Vilfago left a reply on Updating HasMany Relationship • 1 week ago

Do not set phone number to luggage, only to the user. And retrieve the phone number of the user who own the luggage with your relation.

Vilfago left a reply on How To Convert Row Data To Column Data In Laravel • 1 week ago

Short answer : with <td> tags.

Long answer will need example of data you have in your DB, and an example of the output you want.

Vilfago left a reply on How To Insert Array Of Data Into Single Table? • 1 week ago

Not a working code, but it will give you a hint.

foreach($request('imageName') as $image)
{
    $image->save();
}

Vilfago left a reply on Not Working Button Delete Post At Laravel 5 • 1 week ago

And the url ?

You populate it as it was a named route, but I don't see its name anywhere.

Vilfago left a reply on Not Working Button Delete Post At Laravel 5 • 1 week ago

Which error / behavior did you get ?

When you tried "delete" method, did you changed the methid in the route and in the form ?

19th May, 2018

Vilfago left a reply on Category Name Is Not Showing: Eager Loading • 1 week ago

Category has one field: cat_name.

It should have an id for the relation...

Vilfago left a reply on After Registration, Users Are Redirected To The Login Page. Help Me Debug? • 1 week ago

Just in case, if you use dump($var); to see some information in the process, your login will fail.

I never understood why, but good to know.

Vilfago left a reply on Laravel Query Builder Join Where • 1 week ago

$query = QueryBuilder::for(Advertisement::class)
    ->with(['locations' => function($q) {
        $q->where('longitude', '<', 100)
            ->where('latitude', '<', 500);
        }])
    ->get();

https://laravel.com/docs/5.6/eloquent-relationships#constraining-eager-loads

Vilfago left a reply on 1366 Incorrect String Value, On CSV Import To MySQL DB • 1 week ago

Just to be sure : MySQL don't have the same utf-8 as everyone. You should use utf8-mb4 to have the common "utf-8" formatting.

Vilfago left a reply on After Registration, Users Are Redirected To The Login Page. Help Me Debug? • 1 week ago

As you can have different guard, it's possible. But I agree witjh @Cronix, a table user is for user. And it's better to work with roles/groups or anything else afterwards to differentiate them.

For your case, I think the middleware check only with the default guard. As they aren't logged with the default, they cannot access /home (for default laravel), so they're back to login. So you have to update your midlleware to fit your logic, if you want to stay this way.

Vilfago left a reply on Auth::check() Returns False Always • 1 week ago

I don't know if it will solve your issue, but you can retrieve the user with $request->user().

But I don't remember having issue retrieving user with Auth::user() even with ajax call.

Vilfago left a reply on Auth::check() Returns False Always • 1 week ago

Can we see your code between two ```

Are you able to retrieve the user when showing the form (before sending article)?

Vilfago left a reply on Laravel Auth:make Command • 1 week ago

Use imgur or something similar.

It's not useful to create multiple post for the same issue...

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.