mohammednehru

mohammednehru

Member Since 1 Year Ago

Experience Points
8,070
Total
Experience

1,930 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
73
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 2
8,070 XP
Jul
15
3 weeks ago
Activity icon

Replied to Nested Relationships

Any help?

Jul
14
3 weeks ago
Activity icon

Replied to Nested Relationships

If I have more than one index in services it just grabs the last one.

Invalidation step

array:2 [▼
  "plan" => array:3 [▶]
  "services" => array:4 [▼
    0 => array:3 [▼
      "ar_name" => "service 1 in language one"
      "en_name" => "service 1 in language two"
      "number" => "2"
    ]
    1 => array:3 [▼
      "ar_name" => "service 2 in language one"
      "en_name" => "service 2 in language two"
      "number" => "5"
    ]
    2 => array:3 [▼
      "ar_name" => "service 3 in language one"
      "en_name" => "service 3 in language two"
      "number" => "8"
    ]
    3 => array:3 [▼
      "ar_name" => "service 4 in language one"
      "en_name" => "service 4 in language two"
      "number" => "12"
    ]
  ]
]

Data

array:2 [▼
  "plan" => array:3 [▶]
  "services" => array:1 [▼
    0 => array:3 [▼
      "ar" => array:1 [▼
        "name" => "service 4 in language one"
      ]
      "en" => array:1 [▼
        "name" => "service 4 in language two"
      ]
      "number" => "12"
    ]
  ]
]

Data function

    protected function data()
    {
        foreach (request('services') as $service) {
            // dd($service);
            $ar_name = $service['ar_name'];
            $en_name = $service['en_name'];
            $number = $service['number'];

            $newData = [
                'ar' => [
                    'name' => $ar_name,
                ],
                'en' => [
                    'name' => $en_name,
                ],
                'number' => $number,
            ];
        }

        return ([
            'plan' => [
                'ar' => [
                    'name' => request('plan.ar_name'),
                ],
                'en' => [
                    'name' => request('plan.en_name'),
                ],
                'price' => request('plan.price')
            ]
        ] +
            ['services' => [
                $newData
            ]]);
    }
Activity icon

Replied to Nested Relationships

My issue that I'm not able to get data, but @jeffreyvanrossum told me to use foreach but I get only one record, Although I add two

Activity icon

Replied to Nested Relationships

I'm just getting the one record of two

array:2 [▼
  "plan" => array:3 [▼
    "ar" => array:1 [▶]
    "en" => array:1 [▶]
    "price" => "2342"
  ]
  "services" => array:1 [▼
    0 => array:3 [▼
      "ar" => array:1 [▼
        "name" => "service two in language one"
      ]
      "en" => array:1 [▼
        "name" => "service two in language two"
      ]
      "number" => "5"
    ]
  ]
]
Activity icon

Started a new Conversation Nested Relationships

Hi,

I'm trying to access data from the request, I can for 'plan' but always return null in 'services'

This is my request and the same result here when dumping the validated data

array:3 [▼
  "_token" => "C76EvO3bpW4K7e2ogs20373OCkVxj9p1Lbv8fwcO"
  "plan" => array:3 [▼
    "price" => "2342"
    "ar_name" => "name in language one"
    "en_name" => "name in language two"
  ]
  "services" => array:2 [▼
    0 => array:3 [▼
      "ar_name" => "service one in language one"
      "en_name" => "service one in language two"
      "number" => "2"
    ]
    1 => array:3 [▼
      "ar_name" => "service two in language one"
      "en_name" => "service two in language two"
      "number" => "5"
    ]
  ]
]

ValidatedData function

    protected function validatedData()
    {
        return request()->validate([
            'plan.ar_name' => 'required',
            'plan.en_name' => 'required',
            'plan.price' => 'required',
            'services.*.ar_name' => 'required',
            'services.*.en_name' => 'required',
            'services.*.number' => 'required',
        ]);
    }

Data function

    protected function data()
    {
        return ([
            'plan' => [
                'ar' => [
                    'name' => request('plan.ar_name'),
                ],
                'en' => [
                    'name' => request('plan.en_name'),
                ],
                'price' => request('plan.price')
            ]
        ] +
            ['services' => [
                [
                    'ar' => [
                        'name' => request('services.*.ar_name'),
                    ],
                    'en' => [
                        'name' => request('services.en_name'),
                    ],
                    'number' => request('services.number')
                ],
            ]]);
    }

this is what data() returns

array:2 [▼
  "plan" => array:3 [▼
    "ar" => array:1 [▼
      "name" => "name in language one"
    ]
    "en" => array:1 [▼
      "name" => "name in language two"
    ]
    "price" => "2342"
  ]
  "services" => array:1 [▼
    0 => array:3 [▼
      "ar" => array:1 [▼
        "name" => null
      ]
      "en" => array:1 [▼
        "name" => null
      ]
      "number" => null
    ]
  ]
]
Jul
08
1 month ago
Activity icon

Started a new Conversation Eloquent Many To Many Relationships

Hi, I have plans table, services table, and pivot to link them with Many To Many relationships.

plans table

    public function up()
    {
        Schema::create('plans', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->timestamps();
        });
    }

services table with the pivot

    public function up()
    {
        Schema::create('services', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('icon');
            $table->timestamps();
        });

        Schema::create('plan_service', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('plan_id');
            $table->unsignedBigInteger('service_id');
            $table->timestamps();

            $table->unique(['plan_id', 'service_id']);

            $table->foreign('plan_id')->references('id')->on('plans')->onDelete('cascade');
            $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
        });
    }

Now I'm displaying the services in creating plan form to select from them, But I want to select the services and adding a number of each service example: 3 Instagram posts. The number 3 different in each plan with this service.

How I can do this? or in which table I should store the number, Please.

Jul
04
1 month ago
Activity icon

Replied to Checkbox Default

For correction only

$active = ['active' => $request->has('active') ? 1 : 0];

not

$active = ['active' => $request->has('active') ? 1, 0];
Activity icon

Started a new Conversation Checkbox Default

Hi, I'm trying to store status using a checkbox but when form submitted always the default value saved = 0 and when unchecked it does not store the data.

Schema::create('sections', function (Blueprint $table) {
            $table->id();
            $table->string('text');
            $table->string('title')->nullable();
            $table->string('image')->nullable();
            $table->tinyInteger('active')->default(0);
            $table->timestamps();
        });
    public function store(SectionRequest $request)
    {

        if (!$request->request->has('active'))
        {
            $request->request->add(['active' => 0]);
        } 

        Section::create($request->except(['_token']));
        return redirect()->route('section.index')->with(['success' => 'Section created']);
    }
      <div class="form-group">
        <div class="checkbox switcher">
          <label for="active">
            <input type="checkbox" id="active" name="active" value="1">
          </label>
        </div>
      </div>
Jul
02
1 month ago
Activity icon

Replied to @error Not Working

It's not working. Is that because I'm using a request file for my rules?

Activity icon

Started a new Conversation @error Not Working

@error not showing any errors in my form screen

this is my code

Controller

    public function postLogin(LoginRequest $request)
    {

        if (auth()->guard('admin')
            ->attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) {
            return redirect()->route('admin.home');
        }
            return redirect()->back();
        
    }

Blade

                    <div class="input-group mb-3">
                        <input type="email" class="form-control" placeholder="البريد الالكتروني" autocomplete="email"
                            required>
                        <div class="input-group-append">
                            <div class="input-group-text">
                                <span>
                                    <ion-icon name="mail-outline"></ion-icon>
                                </span>
                            </div>
                        </div>
                        @error('email')
                        <span class="invalid-feedback">
                            <strong>{{ $message }}</strong>
                        </span>
                        @enderror
                    </div>
Feb
12
5 months ago
Activity icon

Replied to DB Problem On Host

The primary key missing in all tables in host db manager. I added and now it's work Thank you again

Activity icon

Replied to DB Problem On Host

It's work thank you

Activity icon

Replied to DB Problem On Host

This is on my localhost db manager https://ibb.co/481KQ2h

Activity icon

Replied to DB Problem On Host

    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

It's work fine on my localhost

Activity icon

Replied to DB Problem On Host

This users table on host db manager https://ibb.co/7Vr72JC

Activity icon

Started a new Conversation DB Problem On Host

It's work now thank you. But there's a DB problem when registering a new user or adding anything to DB https://k.top4top.io/p_1503m2sz41.png

This is .env

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=boryelpa_yasDB
DB_USERNAME=boryelpa_yasUSER
DB_PASSWORD=12332100mm

database.php

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'boryelpa_yasDB'),
            'username' => env('DB_USERNAME', 'boryelpa_yasUSER'),
            'password' => env('DB_PASSWORD', '12332100mm'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

database name in my host PHPMyAdmin https://g.top4top.io/p_150236a3n3.png

Activity icon

Replied to ON Hosting Problem

It's work now thank you. But there's a DB problem when registering a new user or adding anything to DB https://k.top4top.io/p_1503m2sz41.png

This is .env

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=boryelpa_yasDB
DB_USERNAME=boryelpa_yasUSER
DB_PASSWORD=12332100mm

database.php

        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'boryelpa_yasDB'),
            'username' => env('DB_USERNAME', 'boryelpa_yasUSER'),
            'password' => env('DB_PASSWORD', '12332100mm'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

database name in my host PHPMyAdmin https://g.top4top.io/p_150236a3n3.png

Feb
11
5 months ago
Activity icon

Replied to ON Hosting Problem

I don't have any problem in these files I checked it many times

Activity icon

Replied to ON Hosting Problem

Is there any way to deploy the Laravel app without all these problem. How I deployed it:

  • creating database using MySQL wizard.
  • zip Laravel project files except public and add theme to new folder in main directory.
  • adding the public folder content to public_html and change path in index.php.
Activity icon

Replied to ON Hosting Problem

Same problem

Activity icon

Replied to ON Hosting Problem

No, I didn't touch this file. I found solution that stay I need to add _ to config.php in Bootstrap/cash/config.php But if do this the host database connection will corrupt

Activity icon

Replied to ON Hosting Problem

Yes, I have it.

Activity icon

Started a new Conversation ON Hosting Problem

Hi, I deployed a laravel website using Cpanel and configure everything but when I need to access login or register I get this error.

https://l.top4top.io/p_1502gua9u1.png

Auth::routes(); this is the routes.

Feb
09
6 months ago
Activity icon

Replied to Share Data

I have a single web page application that shows dynamically the stored data by the control panel. So,

  • I have control panel then store the data to a database only admin has access to this page(I have already all the controllers and models for the admin page and work fine).
  • I need this stored data to be displayed in the home view that the user has access to it(I need to create a single view for this data).