Grelav

Grelav

Member Since 1 Year Ago

Experience Points 9,330
Experience Level 2

670 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 52
Lessons
Completed
Best Reply Awards 4
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.

19 Apr
1 month ago

Grelav left a reply on Auth::user() Returns Unexpected User

I have the same problem, it is from Auth::loginUsingId() When using Auth::loginUsingId() and then logout and login with Auth::attempt() the system still holds the old user id from Auth::loginUsingId() when using Auth::check()

@jeffreyway

17 Apr
1 month ago

Grelav left a reply on Get PHP Class Namespace From String

In general if you are inside a class, you can use NAMESPACE constant to get the name of the class name space you are in.

14 Feb
3 months ago

Grelav started a new conversation Disadvantages Of Storing Models Ids In View

Hello developers

I would like to know what are the disadvantage of store / set entity / model id in Html view e.g

<div data-id='{{product->id}}'>
    product Label : {{$product->label}}
</div>

To use the "id" an ajax request to update product or to full view it.

recommendations please

10 Jan
4 months ago

Grelav left a reply on Laravel Working With Money

Am using @d9705996, @patricksj approach.

Grelav left a reply on Laravel Working With Money

@patricksj, @d9705996

Thanks for your directing and for sharing your experience.

Posting this for community I have found this package for handling money in programming https://github.com/moneyphp/money

09 Jan
4 months ago

Grelav left a reply on Laravel Working With Money

logical.

Grelav started a new conversation Laravel Working With Money

Greetings comrades, I have to work with money / finance calculations in my project like calculating the net of a price after discount occur from a coupon and multiple sales.

e.g.

Service price is 12.25 
Coupon Value is 25%
$couponValue = (12.25 * 25) / 100;
$serviceNetValue = 12.25 - $couponValue;

what is the right way to do it. any recommendations ?

07 Jan
4 months ago

Grelav started a new conversation Laravel @include Path - How To Go Back

Hello guys, how to travel backward / up in the directory path.

e.g lets say we are at laravel_root\resources\views I want to @include('..\file_in_resources.blade.php');

still I have file not found error.

05 Jan
4 months ago

Grelav left a reply on Where Are You All From?

Dahya, Lebanon

Grelav left a reply on Apply Middleware Based On Route Parameters

Route::group(['middleware' => 'auth' ], function () {

 // all routes here are reached if the user is authenticated 

 Route::post('store', '[email protected]');


}

Grelav left a reply on Trying To Submit A Registration Form

Please show your form HTML

04 Jan
4 months ago

Grelav left a reply on Disadvantages Of Storing All The Columns Inside A JSON Column.

Pretty declarative post @D9705996

so in brief, this approach isn't for products with customized properties. NoSql Databases are optimal for e-commerce website / systems.

but is useful for less used fields like gender, age, address.

true?

Grelav started a new conversation Disadvantages Of Storing All The Columns Inside A JSON Column.

what are the disadvantages of storing all the columns of a table inside a single JSON column ?

e.g for a user table instead of having this

    Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('firstname');
            $table->string('lastname');
            $table->string('username')->unique();
            $table->string('email')->unique();
            $table->string('password');
            $table->timestamps();            
            $table->rememberToken();
        });

Just do this

    Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
        $table->json('attributes'); // contains all the fields
            $table->timestamps();   
            $table->rememberToken();
        });

03 Jan
4 months ago

Grelav started a new conversation Handle Subscriptions Due Dates In Laravel

Hello guys, I would like to know how to handle subscriptions dates in Laravel.

e.g. 1) if a subscription for a user ends @ 24/1/2019 how in Laravel this should be handled to disable the subscription or do any other action,

e.g 2) when the due date is reached the system is automatically handle things without the need for any external interfere like when the user login check if his/her subscription is valid or not in case its not update the subscription and do whatever next.

Happy New Year Laravel Community . Thanks in advanced

07 Dec
5 months ago

Grelav started a new conversation Where To Sugges Features And Bugs For Laravel

Hello guys, I would like to know where we can suggest features for Laravel framework so Tyler or community can see.

17 Nov
6 months ago

Grelav left a reply on Laravel Subdomain Configure

@JeffreyWay I have just made a post and time appear as from 7 hours ago ???

#newLayoutIssue

Grelav left a reply on Laravel Subdomain Configure

@ahmeddabak @jkenyon your solutions works and each solutions has its optimal use case.

###In My Case I wanted to have different versions of my project, each subdomain run a version with different database and controllers with the same vendors packages versions.

@ahmeddabak solution is optimal for my case @jkenyon solution is more general and has some security concerns for how much I know.

Thanks again Best Regards @

Grelav left a reply on Laravel Subdomain Configure

@ahmeddabak @jkenyon

I appreciate and acknowledge your help guys, thank for your support

I have come to this solution so far.

###Subdomain I have configured the subdomain to point at public_html directory following @ahmeddabak approach.

###Routing I have solve the routing problem by modifying RouteServiceProvider as following:

protected function mapWebRoutes()
    {
        // example: account.mydomain.com
        $subDomain = explode('.',  $_SERVER['HTTP_HOST'])[0];  // account
        if( $subDomain == 'account')
        {            
            Route::middleware('web')
            ->namespace('\App\Http\accountControllers')     
            ->group(base_path('routes/account_domain_web.php'));
        }
        else
        {
            Route::middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/web.php'));
        }

    }

This approach is to separate the controllers of the subdomain by namespaces and the following code to separate the database connection in the route file:

// at the top of the file
Config::set('database.default', 'subdomain_account');

The 'subdomain_account' connection is defined in the \app\database.php

Final thoughts This approach solve the problem of subdomain and give different controllers and database connection still there is the issue to differentiate views resources directory.

any hints & Tips are welcome

14 Nov
6 months ago

Grelav started a new conversation Laravel Subdomain Configure

Hello guys, am using a Cpanel for my VPS and my subdomains are being created at public_html directory which is the public html directory for the main domain.

public_html structore -> css directory -> js directory -> subdomin directory -> index.js -> .htaccess

how I can configure the subdomain to use my laravel app ?

12 Nov
6 months ago

Grelav started a new conversation WhereHas With HasMany Relation

I want to do the following

user::whereHas('psots',  function ($query) {
                $query->whereIn('category_id', [2, 3, 7]);
            })->orderBy('updated_at', 'desc')->paginate($paginateNum);

should this give the right results?

22 Oct
6 months ago

Grelav left a reply on Session Timeout Not Triggering Auth Logout Event

@Snapey It works.

try it your self

setTimeout(function(){

      alert("Yeah It Workes :)");
      
      },15000);
21 Oct
6 months ago

Grelav left a reply on Session Timeout Not Triggering Auth Logout Event

You can use javascript to do that. Settimeout function to be active after the time you expect your session to die and redirect the user to another location

setTimeout(function(){

window.location = 'app/session_times_out' // example to your route.

},60000)
19 Oct
7 months ago

Grelav left a reply on Awobaz/compoships Package Error With Laravel 5.7.6

Just Refreshing the Routes cache solved the issue.

Grelav left a reply on Awobaz/compoships Package Error With Laravel 5.7.6

is there any alternative solution for multi column relationfor belongsTo / hasMany ?

Grelav started a new conversation Awobaz/compoships Package Error With Laravel 5.7.6

Error

Symfony\Component\HttpKernel\Exception\HttpException 

when accessing routes after installing

composer require awobaz/compoships

Package url: https://github.com/topclaudy/compoships

Package description: Compoships offers the ability to specify relationships based on two (or more) columns in Laravel 5's Eloquent. The need to match multiple columns in the definition of an Eloquent relationship often arises when working with third party or pre existing schema/database.

11 Oct
7 months ago

Grelav left a reply on Fetch Error Message Generated By File Upload Validator

try

@if ($errors->has('attachment.1'))
    <span class="error">
        <strong>{{ $errors->first('attachment.1') }}</strong>
    </span>
@endif 

Grelav left a reply on Adding An Image Upload To An AJAX Post Form

guys there is a much simple way to do it for send data

// this way you have all the form data with out the need to append them one by one :).
 var form_data = new FormData( document.getElementById('your_form_id') );

$.ajax({
            method: 'POST',
            url: urlCreateReview,
            data: form_data,
            processData: false,
            contentType: false
        })
                .done(function() {

        });

Grelav left a reply on Fetch Error Message Generated By File Upload Validator

what is the result you see when

dd(errors)
06 Oct
7 months ago

Grelav left a reply on Problem Saving Data Using Laravel And Ajax

// Set this script before any ajax call
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    beforeSend: function() {
    
  },
  complete: function(){
   
  },
});

Grelav left a reply on Problem Saving Data Using Laravel And Ajax

check your routes for the right action

e.g: Route::post('route/to/your/action','[email protected]');

23 Jul
9 months ago

Grelav left a reply on Best Design Tool For Front-end

You have to create another layout for mobile devices

22 May
11 months ago

Grelav left a reply on One Backend With Multiple Frontend?

Lumen is like a light version from Laravel Laravel is the Father of Lumen

Grelav left a reply on Change The Password Field Of Registration From (password) To (x_password)

and you have to update the userRequest.php

public function rules(Request $request)
    {
        $before = Carbon::parse($request['date_of_birth'])->subYears(18)->format("Y-m-d");
        return  [
                'firstname' => 'required|string|min:2|max:255',
                'middlename' => 'sometimes|nullable|min:2|max:255',
                'lastname' => 'required|string|min:2|max:255',
                'email' => 'required|string|email|max:255|unique:users',
                'mobile' => 'required|string|min:7|max:20|unique:users',
                'country' => 'required',
                'region' => 'required|min:2|max:50',
                'address' => 'required|min:10|max:255',
                'date_of_birth' => 'required|date_format:Y-m-d|date|before:'.$before,
                'password' => 'required|string|min:6|confirmed',
                'profile.*' => 'required|image|max:2048',
            ];
    }

the password field should be x_password and the confirmed field in the field in your form too should be as confirmed_x_password

Grelav left a reply on How To Insert Data Into Db Using Model

if you are want to create a record in the database for each of your data events

set the new statment inside the loop and remove the line where you specify the id your id field is auto increment.


            foreach ($data['events'] as $event){
        $match = new Match;
            // remove this line$match->id = $event['idEvent'];
            $match->first_team = $event['strHomeTeam'];
            $match->second_team = $event['strAwayTeam'];
            $match->tournament_id  = $event['idLeague'];
            $match->date = $event['dateEvent'];
            $match->start_date = $event['strDate'];
            $match->spectators = $event['intSpectators'];
            $match->seasion = $event['strSeason'];
            $match->round       = $event['intRound'];
            $match->start_time   =    $event['strTime'];
            $match->save();
            }

Grelav left a reply on How To Insert Data Into Db Using Model

Have you put this in your controller at the top ?

use \App\Models\Match;

Grelav left a reply on How To Insert Data Into Db Using Model

$request contains all your form fields Model represents your table

lets say you have product table with title and price as the fields

$product = new \App\Product // you should have a Product model in the app directory

$product->title = $request['title']; $product->price = $request['price']; $product->save(); // and it is done :)

Grelav started a new conversation Laravel Perfect Practices

Guys I would like to know what are the best approaches and practices for programming Laravel Applications regarding Controllers, Models and Views. what am talking about here what should a controller / Model / View has and what should/must not has or contain. do we create a controller that has only methods for views and another for storing and updating etc... do we always solve repetition of Model Elquent queries with scopes ? how to handel CURD in views ?do we create a single view for creating and editing and the form itself as a partial view ? and same for controller do we create a single method for creating and updating entities ? as nearly the same logic / code is required? am talking about these issues.

Every single task is crucial for me so every single small tiny detail is a favor.

08 May
1 year ago

Grelav left a reply on Controller Is Not Working When Ajax Request Is Fired

You have to add the CSRF TOKEN to your ajax request.


$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});


Grelav started a new conversation Vue Fetch Is Responding With 302 Found And Then Accissing Web Routes

This is my vue code

methods: {
            fetchRoles()
            {
                fetch('/api/roles')
                .then(res => res.json())
                .then(res => {
                    
                    this.roles = res.data;
                })
            }
        }

and this is my api routes code

Route::get('roles', '[email protected]');
02 May
1 year ago

Grelav left a reply on Profile Page Content Not Yet Set

Here you go

$requestRules = [
                'new_password' => 'required|confirmed',                
            ];          

            $validator = Validator::make($request->toArray(), $requestRules,
            [
                 //Please Enter a valid email address
                   'new_password.email' => '1',
            ]);


        if ($validator->fails()) {
            session()->flash('server_message', 'Password Confirmation Error');
            session()->flash('server_message_type', 'warning');
            return redirect()->back()
                        ->withErrors($validator)
                        ->withInput();
        };
01 May
1 year ago

Grelav left a reply on SQLSTATE[HY000] [2006] MySQL Server Has Gone Away Error

It is like order problem

if you run your MySQL server then your local Server the 127.0.0.1 will be taken by Mysql and vice versa.

Change your MySql server ip

Grelav left a reply on Can Not Remove Previous Path Of URL

in your view file the problem should be

use helpers to build the url e.g.

<a href="{{ url('/my/absolute/path/) }}">My Link</a>
29 Mar
1 year ago

Grelav left a reply on Access Array In Object

try

$company_categories = $req->get('company-categories');

@foreach($company as $companyCategory)
       <option value="{{ $companyCategory->id }}">
           {{ $companyCategory->name }}</option>
 @endforeach 

Grelav left a reply on Access Array In Object

You are passing an array

{
    $company : array[]
}

try

@foreach($company as $companyCategory)
       <option value="{{ $companyCategory['id'] }}">
           {{ $companyCategory['name'] }}</option>
 @endforeach 
28 Mar
1 year ago

Grelav left a reply on Sweet Alert And Toast For Laravel

Nicely done Keep up the fantastic work.

Grelav left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'created_at' In 'order Clause'

In Your Modal add the following for your relation withTimestamps();

example

public function categories()
    {
        return $this->belongsToMany('\App\Category')->withTimestamps();
    }

Grelav left a reply on Sparkpost Error : Unable To Find The Socket Transport "starttsl"

Hello Guys for anyone who would face this problem I have been able to solve it by using sparkpost driver in the .env file and updating guzzlehttp/guzzle package.

and make sure you have valid SSL certificate and verified domain in your sparkpost account.

Grelav left a reply on Sparkpost Error : Unable To Find The Socket Transport "starttsl"

@smagic39 I already have setup SSL certificate.

Full Error Message

Connection could not be established with host smtp.sparkpostmail.com [Unable to find the socket transport "starttls" - did you forget to enable it when you configured PHP? #32526]

exception   Swift_TransportException
file    /home/apainter/laravel/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php