Vilfago

Vilfago

Neuch√Ętel

Member Since 9 Months Ago

Experience Points 72,710
Experience
Level
Lessons Completed 68
Lessons
Completed
Best Reply Awards 93
Best Answer
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.

17 Jan
13 hours ago

Vilfago left a reply on Getting Common Methods Outside Controller

Use a trait : http://php.net/manual/en/language.oop5.traits.php

add your function in this trait, and call it at the beginning of your controller.

Vilfago left a reply on How To Secure My Laravel App ?

For your php version, you can only take laravel 5.2, which is not enough for your firewall...

Since laravel 5.6, you have an "in-house" middleware for rate limiting ( https://laravel.com/docs/5.7/routing#rate-limiting ).

So, I think the best is to update your php to a current supported version, and update laravel to a current supported version.

Vilfago left a reply on How To Keep Old Model's Data Until New Changes Are Approved ??

I didn't think about it, but I think you still can store it in a json object.

Vilfago left a reply on Eloquent Mutators And Accessors In Lumen

Yeah... but did you try to set another date ?

I think it will not work.

Vilfago left a reply on WhereHas Using Muliple Tables (or Perhaps Join)

If you don't have so many groups, you can maybe try something like that.

Add a column page_count on users table, and do something like

$groups = Group::all();

foreach($groups as $group){
  $group->load('users' => function($q) use ($group){
    $q->where('page_count', '<', $group->max_pages); });
}

Vilfago left a reply on Eloquent Mutators And Accessors In Lumen

It should be

 $breakingNews = BreakingNews::findOrFail($id);
 $breakingNews->expired_at = Carbon::today()->format('Y-m-d H:i:s'));
 $breakingNews->save();

But in your model, you will always have a $value, so if (!$value) { is not relevant.

You better have to choose a default value in your database as CURRENT_TIMESTAMP.

Vilfago left a reply on Validation

If you want to avoid file SomethingSafe.jpg.exe, don't worry, as it's checked on mime type, so if it's a .exe, the validation will fail.

Vilfago left a reply on I'm Trying To Get Css Style File According To Language In Laravel.. But Not Working

You have a strange folder structure :)

You can thus select a best answer to close the thread.

Vilfago left a reply on WhereHas Using Muliple Tables (or Perhaps Join)

I think you will go for a query builder with some join and raw sql here...

Vilfago left a reply on How To Keep Old Model's Data Until New Changes Are Approved ??

Maybe with another table and model BookChange with a column for the type of change (delete or update) and a nullable field with a json with the new book after change (in case of update) and a book_id.

Until admin approves, no change are considered in the Book model, and when approved, you retrieve the json, update Book with it and delete the BookChange.

Vilfago left a reply on I'm Trying To Get Css Style File According To Language In Laravel.. But Not Working

Yes... as @nagm_star said, check your source code in the browser.

Really strange that your url begins with ".".

I expect something like

 <link href="asset('/css/style'.app()->getlocale() == 'ar' ? '-ar' : '-en'.'.css')" rel="stylesheet"> 

Vilfago left a reply on I'm Trying To Get Css Style File According To Language In Laravel.. But Not Working

What's not working ?

An error, unepexcted behavior ?

Vilfago left a reply on WhereHas Using Muliple Tables (or Perhaps Join)

I don't see how you can do this without using raw sql from query builder.

The other way is to store a "page_count" on user, it could be more efficient if this request is often launched.

16 Jan
1 day ago

Vilfago left a reply on Popper.js.map - Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

Choose your answer as best answer, it's make more probable that someone else find this thread.

Vilfago left a reply on How To Count In Jquery Each Function

@PICKAB00 - It's really hard to say without seeing all the code in question

Vilfago left a reply on Problems With Paginate (), Do Not Load All Lists In Laravel 5.5

because you get some data, so it's a get method.

Vilfago left a reply on How To Count In Jquery Each Function

How did you push data in shoppingCart ?

Vilfago left a reply on How To Count In Jquery Each Function

console.log(shoppingCart.length)

Vilfago left a reply on Problems With Paginate (), Do Not Load All Lists In Laravel 5.5

so use : Route::get('/panel/bestado', '[email protected]')->name('usuario.bestado');

Vilfago left a reply on Problems With Paginate (), Do Not Load All Lists In Laravel 5.5

paginate use GET request, is your route a POST or something else ?

Vilfago left a reply on Best Laravel Version To Have With Existing Php ?

Which host did you have that cannot run on PHP 7.x ?

Vilfago left a reply on Popper.js.map - Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

What is the content of package.json ?

And could you provide the lines on package-lock.json that contains "popper" ?

Vilfago left a reply on Is App Config 'fallback_locale' Mandatory?

It's just a "security", but you don't need it :

You may configure a "fallback language", which will be used when the active language does not contain a given translation string.

Vilfago left a reply on Getting A Variable To Be Passed To My Store Function

Yes... but it don't change what I think on the process.

Vilfago left a reply on Best Practice For Dynamic Permission In Field Level

Nice, so you have your solution ;)

Do you see how you should set your relations ?

Vilfago left a reply on Unexpected Identifier On Javascript Import Statement

It seems that some information are missing in your post.

Vilfago left a reply on Best Practice For Dynamic Permission In Field Level

Using group of permission ? Or role group with standard permission ? Or a mix of the 3 solutions above ?

Vilfago left a reply on Validation

What is the error ? Which is the data you provided ?

Vilfago left a reply on Validation

Because it should correspond to your regex, and if it's blank, it's not.

try : 'deptcode'=>'sometimes|regex:/^[a-zA-Z0-9 _,.-]+$/',

Vilfago left a reply on Add Multiple Variable To View

public function index() { $variables = DB::table('OnlineSurveyData_analytics_dump_variables')->get(); $header = DB::select("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'OnlineSurveyData_analytics_dump'"); $variables = json_decode(json_encode($variables, true)); $tbHead = json_decode(json_encode($header, true)); $sque = 'This is string Value for thrid variable'; return view('admin/crosstabdata')->with('variables', $variables)->with('tbHeading', $tbHead)->with('sque', $sque); }

Vilfago left a reply on Getting A Variable To Be Passed To My Store Function

How do you handle two images with the same name ?

I guess you upload image with an ajax before submitting the form ?

IF it's the case, you cannot retrieve the $image from the other method, as the request is already done/closed.

You have to pass your json $image in the form (by example an hidden field), and retrieve it in the $request.

Vilfago left a reply on Validation

FYI, you will have space with this regex

15 Jan
2 days ago

Vilfago left a reply on Laravel Custom Form Request Get Id

Not sure, but can try

return [
        'title' => 'required|string|min:3|max:15|unique:shops,title,' .optional($this->id),
    ]

Vilfago left a reply on Laravel Custom Form Request Get Id

use $this->route('id')

Vilfago left a reply on Triple Pivot Table

A user can have many companies, but he has only one role per company, or multiple ?

Vilfago left a reply on Is There A Way To Sort A Collectin Using SortBy($key, 'asc/desc')?

No, and, no. Unfortunately.

SortBy is a sort on an object (the collection).

OrderBy is an injonction to your database engine to sort the result before sending them to your backend. This is far more powerful and efficient to sort your data at this level, as database engine are optimized for this work (if you use index on the relevant column).

Vilfago left a reply on What It's The Cleaner Database Design For This Needs

Back to the first question : what's difference between your 3 users ?

Do you really need to add complexity with 3 differents table / model, or it could just be an attribute of the user (i.e you have some user group to manage permission).

Vilfago left a reply on What It's The Cleaner Database Design For This Needs

What is the difference between a user and a teacher/student ?

Have a look to polymorphic relation for "favoritable" (i.e. commentable in the doc) https://laravel.com/docs/5.6/eloquent-relationships#polymorphic-relations

Vilfago left a reply on Add Multiple Variable To View

@ZION - same error

Probably not, as it's no more a constant but a variable...

Help yourself, give us proper information

Vilfago left a reply on Add Multiple Variable To View

please, put all your code between two ```

And writing again and again the same line of code doesn't help much.

Try

return view('admin/crosstabdata', ['secheader' => $secheader, 'tbHeading' => $tbHeading, 'variables' => $variables]);

Which version of laravel do you use ?

Vilfago left a reply on Add Multiple Variable To View

$header = DB::select("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'sometableOne'");
$secHeader = DB::select("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'sometableTwo'");
$foo= DB::table('sometableOne')->get();

return view('admin/crosstabdata', compact('secValHead','tbHeading','foo'));

print_r($foo);

Vilfago left a reply on Where Clause To Validation Request

public function rules()
{
    $userId = auth()->id();
    return [
        'coin' => Rule::unique('trackers')->where(function ($query) use($userId) {
            return $query->where('user_id', $userId);
        })
    ];
}

Vilfago left a reply on Best Practice For Dynamic Permission In Field Level

As @bobbybouwmann said, you add a permissions table, and a pivot table permissions_users.

permissions contains all the actions that you want to allow. You set the relations between User and Permission as ManyToMany (https://laravel.com/docs/5.6/eloquent-relationships#many-to-many).

And last, you create a form in order to let the admin attach or detach permission to user (https://laravel.com/docs/5.6/eloquent-relationships#updating-many-to-many-relationships).

Vilfago left a reply on Eloquent WhereHas With Latest Relationship Record

It was a try to clarify it for ManyToMany relations, but it's right that in your case, it's not cleaner.

You should maybe have a look to the query created by Eloquent to see what's wrong, but you probably reach the current limit of Eloquent, and have to rely on the Query Builder (and maybe raw expressions https://laravel.com/docs/5.7/queries#raw-expressions) to handle your case.