NOMGUY

Member Since 1 Year Ago

Experience Points
74,700
Total
Experience

300 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
632
Lessons
Completed
Best Reply Awards
11
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 15
74,700 XP
Nov
21
3 months ago
Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`employees`, CONSTRAINT `employees_designation_id_foreign` FOREIGN KEY (`designation_id`) REFERENCES `designations`

Okay @kanchan186 . No problem. There's a simple hack which could let you keep going. Just replace the code of up() function with this:

Schema::disableForeignKeyConstraints();
        Schema::create('employees', function (Blueprint $table) {
            $table->increments('emp_id');
            $table->string('emp_fname');
            $table->string('emp_lname');
            $table->date('emp_bdate');
            $table->string('gender');
            $table->integer('emp_mobile')->unique();
            $table->integer('emp_alt_mobile')->unique();
            $table->string('emp_email')->unique();
            $table->string('emp_address');
            $table->string('emp_photo');
            $table->string('emp_username');
            $table->string('password');
            $table->string('emp_state');
            $table->string('emp_city');
            $table->string('emp_country');
            $table->integer('emp_pincode');
            $table->string('emp_id_proof');
            $table->integer('login_first');
            $table->timestamps();
        });
         Schema::table('employees', function (Blueprint $table) {
            $table->integer('department_id')->unsigned()->after('emp_id');
            $table->foreign('department_id')->references('department_id')->on('departments')->onDelete('cascade')->change();

            $table->integer('designation_id')->unsigned()->after('department_id');
            $table->foreign('designation_id')->references('designation_id')->on('designations')->onDelete('cascade')->change();

            $table->integer('report_to_id')->unsigned()->after('designation_id');
            $table->foreign('report_to_id')->references('emp_id')->on('employees')->onDelete('cascade')->change();
           
        });
Schema::enableForeignKeyConstraints();

And let me know if it helps.

Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`employees`, CONSTRAINT `employees_designation_id_foreign` FOREIGN KEY (`designation_id`) REFERENCES `designations`

Hey @kanchan186 I believe you already have some data in designations table in the database. If so, this is the reason for the error. You need to empty that table first then hit the migration. If you cannot delete the table data, you need to pass it like this:

$table->integer('designation_id')->unsigned()->after('department_id')->nullable();
Nov
14
3 months ago
Activity icon

Replied to Is It Worth Following The 5.7 Laravel Tutorials If I've Installed Version 6?

Hey @marinad I believe you should switch to Laravel 6 tutorials (https://laracasts.com/series/laravel-6-from-scratch). Not much have changed from Laravel 5.7 to Laravel 6. But it would be better to stay updated with the official tutorials and documentation.

Activity icon

Replied to Unique Values

It has to be like:

$rules = [
            'denomination' => 'required|unique:denominations,denomination' ,
            'denominationgroup' => 'required',  
];
Activity icon

Replied to Add Foreign Key In Migration

Hey @artisticre You are getting that error as you already have data in your posts table and you are then applying foreign key. You should set it to default null or else it will throw the same error. Try:

$table->integer('category_id')->unsigned()->default(null); or $table->integer('category_id')->unsigned()->default(' ');
$table->foreign('category_id')->references('id')->on('categories');
Activity icon

Replied to Prevent User From Ordering More Than The Placed Tickets

Hey @matildah As per my understanding you want something like if for a particular event, tickets are placed by a certain user, then he/she should not be able to again book the tickets for the same event. Right?

Activity icon

Replied to Migrations Broken After Updating From Laravel 5.7 To 5.8

Hey @squibby Could you please tell what was the type of response earlier? i agree with @tray2

Nov
13
3 months ago
Activity icon

Replied to Update Two Tables In A Store Function

Sorry dude. I don't think I am getting what you're trying to say. It's just the way you are elaborating it. No offence. I hope someone might help you.

Activity icon

Replied to Update Two Tables In A Store Function

This is not understandable: i need when a user stores a ticket the column booked seats in events table is updated by adding regular_quantity and vip_quantity

Activity icon

Replied to Update Two Tables In A Store Function

@matildah Could you please write it properly? I think you're messing up the things.

Activity icon

Replied to Validating A "Description" Field

Hey @kreierson ! I think you on't need any other validation rule for description field than required. Only think I would like to say is that instead of taking that column a text type you should change it to longText.

Nov
12
3 months ago
Activity icon

Replied to Naming Routes Ideas

No problem. Cheers!

Activity icon

Replied to Naming Routes Ideas

Hey @anyb1s Resourceful routes are the routes which comes with the skeleton of the basic CRUD operations. For ex, if you hit this in your project,

php artisan make:controller TestController --resource

it will create a controller named TestController with index, create, store, show, edit, update and destroy function in it by default. So, if you want to use it in the routes, it'll be like:

Route::resource('test', 'TestController');

So, if you have a index.blade.php file which has a button called Create Post or Create Test, the the code for it looks like:

<a href="{{ route('test.create') }}" class="btn btn-success">Create Post</a>

which will take you to the create function of TestController. Similarily for others too (edit, update, store, index, destroy, show).

If I talk about your route, if you want it to be accessed on a button click, thenyou should write something like:

<a href="{{ route('invoices.pay', $invoice->id) }}" class="btn btn-default">Send</a>

Note: $inoice->id is the parameter you expect

Route::put('invoices/{invoice}/send', '[email protected]')->name('invoices.pay');

in this route at {invoice}. I hope it helps you. Let me know if you want to know anything else.

Nov
06
3 months ago
Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

Hey @tykus I believe what @nanadjei2 wanted to get was, if you have three tables with data. First Configuration table like:

'id' => 1,
'name'  => 'test'

Shoe table like:

'id'    => 1,
'name'  => 'dummy'

and Category table like:

'id'    => 1,
'name ' => 'demo'

All he wanted is data like:

[
    [configs]   => [
        [id]    => 1
        [name]  => test
    ],
    [shoes] => [
        [id]    => 1
        [name]  => dummy
    ],
    [cats]  => [
        [id]    => 1
        [name]  => demo
    ],
];

Something like this.

Activity icon

Awarded Best Reply on Eloquent Or Query Builder Select All From Multiple Tables

@nanadjei2 Then you must take them in different variables and merge at last. Like:

$configs = Configuration::all();
$shoes = Shoe::all();
$mix = array_merge($configs, $shoes);

$cats = Category::all();
$data = array_merge($mix, $cats);

Or you could try:

$dataArr = [];
$configs = Configuration::all();
$shoes = Shoe::all();
$cats = Category::all();

$dataArr = [
    'configs'=> $configs,
    'shoes' => $shoes,
    'cats'  => $cats
];

This one might help you achieve the solution.

Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

@nanadjei2 Then you must take them in different variables and merge at last. Like:

$configs = Configuration::all();
$shoes = Shoe::all();
$mix = array_merge($configs, $shoes);

$cats = Category::all();
$data = array_merge($mix, $cats);

Or you could try:

$dataArr = [];
$configs = Configuration::all();
$shoes = Shoe::all();
$cats = Category::all();

$dataArr = [
    'configs'=> $configs,
    'shoes' => $shoes,
    'cats'  => $cats
];

This one might help you achieve the solution.

Activity icon

Replied to Redirect Link Is Not Working

Hey @masumluf What if you write your route like:

Route::group(['prefix' => 'student', 'middleware' => 'student'], function () {
    Route::get('index', '[email protected]');
});

and then try to hit it? Note: Remember to make it

protected $redirectTo = '/student/index';
Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

Hey @nanadjei2 You can try like:

Configuration::selectRaw('configurations.* as configs', 'shoes.* as shoes', 'categories.* as cats')
                ->where('configurations.product_id', '$product->id')        // Please use your relation
                ->join('shoes', 'shoes.config_id', 'configurations.id')
                ->join('categories', 'categories.shoe_id', 'shoes.id')
                ->get();
Activity icon

Replied to Route Group

Hey @davy_yg Here "prefix" is used as to hit the url with it. For example, if you look at:

Route::group(['prefix' => 'user', 'namespace' => 'Admin'], function() {
    Route::get('/', '[email protected]')->name('user.index');
});

If you want to access that page, then you need to hit

localhost:8000/user

Similarly for others too.

localhost:8000/user/create
localhost:8000/user/store
and so on...

"Namespace" is used as to tell the routes that your "UserController" is not present at "App/Controllers/UserController" folder. Instead it is present at "App/Controllers/Admin/UserController" folder. Hope it helps. Thanks!

Activity icon

Replied to Create Global Variable In Laravel

Hey @muath-ye

Check this: If you add something like this

<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;

class DummyController extends Controller
{
    public function dummy()
    {
    $user = 'Testing';  

        app()->instance('Dummy', $user);
    }
}

Once you have given app()->instance some data, you can use it anywhere in the app like:

$result = resolve('Dummy');
print_r($result);   // Testing
Sep
05
5 months ago
Activity icon

Replied to How Can I Stop Form Re-submitting After Clicking Browser Reload

Some code would be nice to start with. :)