iroxbir

Member Since 4 Months Ago

Experience Points
4,580
Total
Experience

420 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
1
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
4,580 XP
Feb
23
2 days ago
Activity icon

Replied to View Not Found

@michaloravec

YOU ARE A FATHER DOG AND MOTHER DOG...

Jan
30
3 weeks ago
Activity icon

Replied to How To Display The Number Of Products In That Category?

@michaloravec

I swear to God that I do not intend to interfere in this free forum.

I just have a difficult project for the first time that I can not solve.

And I think in the next project I do not need to ask the forum.

I am a job of programming Laravel. I love Laravel.

I tried in watches but I did not solve my problem.

So you don't question as spam, Please.

Activity icon

Started a new Conversation How To Display The Number Of Products In That Category?

blade

{{ $category->whereHas('products')->count() }}

Category.php

public function products()
{
    return $this->hasMany(Product::class, 'rootCategoryId');
}
Jan
29
3 weeks ago
Activity icon

Replied to Failed To Open Stream: Disk Quota Exceeded

Note: My site is multilingual.

Activity icon

Replied to Failed To Open Stream: Disk Quota Exceeded

Does anyone know what the problem is?

Activity icon

Started a new Conversation Failed To Open Stream: Disk Quota Exceeded

What is this error?

error

Middleware/Language.php

public function handle($request, Closure $next)
{
    $locale = $request->segment(1);
    if (!array_key_exists($locale, config('app.locales'))){
        $segments = $request->segments();
        $segments[0] = config('app.fallback_locale');
        return redirect(implode('/', $segments));
    }
    app()->setLocale($locale);
    return $next($request);
}
Jan
26
4 weeks ago
Activity icon

Replied to How To Define Name For Slug?

I sent it accidentally

it is

Missing required parameters for [Route: about] [URI: pageSlug}]. (View: C:\xampp3\htdocs\projects\resources\views\Home\layouts\header.blade.php)

Activity icon

Started a new Conversation How To Define Name For Slug?

Look at my codes.

web.php

Route::get('/{pageSlug}', '[email protected]')->name('about');

RouteServiceProvider.php

public function boot()
{
    Route::bind('pageSlug', function ($value) {
        return Page::whereSlug($value)->firstOrFail();
    });
    parent::boot();
}

blade

<a class="nav-link" href="{{ route('about') }}">About</a>

I see this error

Missing required parameters for [Route: contact] [URI: pageSlug}]. (View: C:\xampp3\htdocs\projects\resources\views\Home\layouts\header.blade.php)

Activity icon

Replied to How Ti Create Simple Page?

I want to get from the database.

And my customer tells me. Just be http://site.com/about

Activity icon

Started a new Conversation How Ti Create Simple Page?

I have 3 languages and I want to create a simple page for example about-us

Controller

public function about(Page $page)
{
    return view('Home.pages.about', compact('page'));
}

blade

@dd($page->title)

web.php

Route::get('/about', '[email protected]')->name('about');

I see null

Jan
24
1 month ago
Activity icon

Started a new Conversation Method App\Http\Requests\MarketRequest::move Does Not Exist.

Look at my codes, Please.

public function update(MarketRequest $request, Market $market)
{
    $fileName = $market->image == $market->image ? $market->image : null;
    if ($request->hasFile('image')) {
        $file = $request->file('image');
        $name = time();
        $extension = $file->getClientOriginalExtension();
        $fullName = $name . '.' . $extension;
        $fileName = $request->move(public_path('images/markets'), $fullName);
    }
    $data = [
        'user_id' => auth()->id(),
        'title' => $request->title,
        'body' => $request->body,
        'lang' => $request->lang,
        'price' => $request->price,
        'status' => $request->has('status'),
        'image' => $fileName
    ];
    $market->update($data);
    $market->categories()->sync($request->category_id);
    return redirect()->route('markets.index');
}

Error

Method App\Http\Requests\MarketRequest::move does not exist.

Jan
23
1 month ago
Activity icon

Replied to How To Save User_id With Request All?

@michaloravec

I get this error.

Undefined property: Illuminate\Auth\AuthManager::$id

Jan
22
1 month ago
Activity icon

Started a new Conversation How To Save User_id With Request All?

I have a user_id in categories table. i try for save it, But I don't solve my problem.

public function store(CategoryRequest $request)
{
    $category = Category::create($request->all());
    $category->save();
    return redirect(route('categories.index'));
}

error

SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value (SQL: insert into categories (name, updated_at, created_at) values (کالای دیجیتال, 2021-01-23 02:34:36, 2021-01-23 02:34:36))

Activity icon

Replied to How To Update Image?

You tested it.

I updated the photo twice and it turned out like this.

https://i.stack.imgur.com/iNX2R.png

Activity icon

Started a new Conversation How To Update Image?

I have an image in database and when ] update a table , The image disappears and becomes null.

Before update

image

After update

image

public function update(SlideShowRequest $request, SlideShow $slideShow)
{
    $fileName = null;
    if ($request->hasFile('image'))
    {
        $file = $request->file('image');
        $name = time();
        $extension = $file->getClientOriginalExtension();
        $fileName = $name . '.' . $extension;
        $file->move(public_path('images/slideShows'), $fileName);
    }
    $data = [
        'user_id' => 1, //auth()->id(),
        'image' => $fileName,
        'lang' => $request->lang
    ];
    $slideShow->update($data);
    return redirect()->route('slideShows.index');
}L
Activity icon

Replied to Undefined Variable: FileName

I see this error again

SQLSTATE[HY000]: General error: 1364 Field 'image' doesn't have a default value (SQL: insert into slide_shows (user_id, updated_at, created_at) values (1, 2021-01-22 13:53:29, 2021-01-22 13:53:29))

Activity icon

Started a new Conversation Undefined Variable: FileName

How to upload images and save it?

public function store(SlideShowRequest $request)
{
    if ($request->hasFile('image'))
    {
        $file = $request->file('image');
        $name = time();
        $extension = $file->getClientOriginalExtension();
        $fileName = $name . '.' . $extension;
        $file->move(public_path('images/slideShows'), $fileName);
    }
    SlideShow::create([
        'user_id' => 1, //auth()->id(),
        'image' => $fileName,
        'lang' => $request->lang
    ]);
    return redirect()->route('slideShows.index');
}

it has an error

Undefined variable: fileName

Jan
20
1 month ago
Activity icon

Replied to Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

After it, for install authentication, What am I doing now?

Activity icon

Started a new Conversation Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

When I install laravel/UI, I see this error.

error

My laravel version is 7.

Jan
19
1 month ago
Activity icon

Started a new Conversation How To Get Full_name

User.php

public function getFullNaneAttribute()
{
    return $this->first_name . ' ' . $this->last_name;
}

blade

<td>{{ $faq->user->full_name }}</td>
Jan
16
1 month ago
Activity icon

Started a new Conversation How To Install On Git?

How to install on git?

error

Activity icon

Started a new Conversation How To Save Data When I Delete A Row Or Id?

My form is like this I have four row in database

second

May admin delete 2 rows or id.

first

How to save it

public function important_store(SettingRequest $request)
{
    $importants = collect([]);
    if ($request->importants) {
        foreach ($request->helps as $help) {
            $model = Important::updateOrCreate([
                'title' => $help['title']
            ], [
                'link' => $help['link']
            ]);
            $importants->push($model);
        }
    }
    Help::whereNotIn('id', $importants->pluck('id'))->delete();
    return redirect()->back();
}
Activity icon

Started a new Conversation Bootstrap 4.5.3 Grid System Layout Not Working

grid system

I'm trying to do a layout with bootstrap, but I can't figure it out what I'm doing wrong. I'm putting 3, but it's not working.

<div class="p-5">
    <h3><i class="fas fa-cog ml-2"></i>settinga</h3>
    <div class="container">
        <div class="row">
            <div class="col-4">
                <div class="card">
                    <a href="{{ route('helps.index') }}" class="btn btn-success">help</a>
                    <a href="{{ route('importants.index') }}" class="btn btn-success">link</a>
                    <a href="{{ route('socials.index') }}" class="btn btn-success">title</a>
                </div>
            </div>
        </div>
    </div>
</div>
Jan
15
1 month ago
Activity icon

Replied to How To Save Dynamic Form In Laravel?

What a beautiful advice

Activity icon

Replied to How To Save Dynamic Form In Laravel?

I change this line

my blade

countHelp++;

function addDynamicHelp(number) {
    let html = '' +
        '<div class="row mb-2">\n' +
        '<div class="col-md-4">\n' +
        '<input class="form-control" placeholder="Title" name="helps['+countHelp+'][title]">\n' +
        '</div>\n' +
        '<div class="col-md-4">\n' +
        '<input class="form-control" placeholder="Link" name="helps['+countHelp+'][link]">\n' +
        '</div>\n' +
        '<div class="col-md-2">\n' +
        '<a class="btn btn-primary addHelp">Add</a>\n' +
        '<a class="btn btn-danger delete">Delete</a>\n' +
        '</div>\n' +
        '</div>\n' +
        countHelp++;
    $('#showDynamicHelp').append(html);
}

controller

public function help_store(SettingRequest $request)
{
    $helps = collect([]);
    if ($request->helps) {
        foreach ($request->helps as $help) {
            $model = Help::updateOrCreate([
                'title' => $help['title']
            ], [
                'link' => $help['link']
            ]);
            $helps->push($model);
        }
    }
    Help::whereNotIn('id', $helps->pluck('id'))->delete();
    return redirect()->back();
}

SettingRequest

public function rules()
{
    return [
        'helps' => 'required|array',
        'helps.*.title' => 'required|string',
        'helps.*.link' => 'required|string',
    ];
}

This code do not not delete first row or first id.

Activity icon

Replied to How To Save Dynamic Form In Laravel?

@michaloravec

I change like your code , But it did not save in database

Activity icon

Replied to How To Save Dynamic Form In Laravel?

YES , I added like this . but it did not save in database

Activity icon

Replied to How To Save Dynamic Form In Laravel?

I added a validation like this.

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SettingRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required',
            'link' => 'required',
        ];
    }
}

but it does not save anything.

Activity icon

Replied to How To Save Dynamic Form In Laravel?

I also added validation but it does not save anything.

Activity icon

Started a new Conversation How To Save Dynamic Form In Laravel?

I Have a for where you can add multiple lines by click on a button and I want to store the data into the database

This is the error I get when I submit the form - Array to string conversion

Form inputs I didn't post the form element since I don't think I needed to show it here.

 <input type="text" class="form-control" name="title[]" />
 <input type="text" class="form-control" name="link[]" />

Controller

public function help_store(Request $request)
{
    $helps = collect([]);
    if ($request->title) {
        foreach ($request->title as $key => $title) {
            $model = Help::updateOrCreate([
                'title' => $title
            ], [
                'link' => $request->link[$key]
            ]);
            $helps->push($model);
        }
    }
    Help::whereNotIn('id', $helps->pluck('id'))->delete();
    return redirect()->back();
}

I see this error

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null (SQL: insert into helps (title, link, updated_at, created_at) values (?, ?, 2021-01-15 20:02:42, 2021-01-15 20:02:42))

Activity icon

Replied to Homebrew

And what is sudo?

Activity icon

Replied to Homebrew

I have a windows 10. what am i doing?

Activity icon

Started a new Conversation Homebrew

I am watch laravel https://laracasts.com/series/laravel-6-from-scratch Section 2 .

And I did not work with homebrew https://brew.sh/ .

What is https://brew.sh/ ?

Jan
13
1 month ago
Activity icon

Replied to Undefined Index: Id Laravel

Version 7

Activity icon

Replied to Undefined Index: Id Laravel

I repeated it

    return new Product([
        'id' => $row['id'],

And

    return Product::updateOrCreate([
        'id' => $row['id']
    ], [

But I see this error

Call to undefined method Modules\Product\Entities\Product::upsert()

Activity icon

Replied to Undefined Index: Id Laravel

When I write

public function model(array $row)
{
    dd($row);

I see this

dd

Activity icon

Replied to Undefined Index: Id Laravel

My complete code is this, but my problem did not solve yet.

<?php

namespace App\Imports;

use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithUpserts;
use Modules\Product\Entities\Product;

class ProductImport implements ToModel, WithUpserts
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return Product::updateOrCreate([
            'id' => $row['id']
        ], [
            'title' => $row['title'] == 'NULL' ? null : $row['title'],
            'slug' => $row['slug'] == 'NULL' ? null : $row['slug'],
            'rootCategoryId' => $row['rootcategoryid'] == 'NULL' ? null : $row['rootcategoryid'],
            'description' => $row['description'] == 'NULL' ? null : $row['description'],
            'full_description' => $row['full_description'] == 'NULL' ? null : $row['full_description'],
            'type' => $row['type'] == 'NULL' ? null : $row['type'],
            'price' => $row['price'] == 'NULL' ? null : $row['price'],
            'is_special' => $row['is_special'] == 'NULL' ? null : $row['is_special'],
            'is_special_started_at' => $row['is_special_started_at'] == 'NULL' ? null : $row['is_special_started_at'],
            'is_special_ended_at' => $row['is_special_ended_at'] == 'NULL' ? null : $row['is_special_ended_at'],
            'sale_price' => $row['sale_price'] == 'NULL' ? null : $row['sale_price'],
            'sale_started_at' => $row['sale_started_at'] == 'NULL' ? null : $row['sale_started_at'],
            'sale_ended_at' => $row['sale_ended_at'] == 'NULL' ? null : $row['price'],
            'keywords' => $row['keywords'] == 'NULL' ? null : $row['keywords'],
            'sort_order' => $row['sort_order'] == 'NULL' ? null : $row['sort_order'],
            'thumbnailId' => $row['thumbnailid'] == 'NULL' ? null : $row['thumbnailid'],
            'status' => $row['status'] == 'NULL' ? null : $row['status'],
            'stock' => $row['stock'] == 'NULL' ? null : $row['stock'],
            'closed_comments' => $row['closed_comments'] == 'NULL' ? null : $row['closed_comments'],
            'published_at' => $row['published_at'] == 'NULL' ? null : $row['published_at'],
        ]);
    }

    /**
     * @return string|array
     */
    public function uniqueBy()
    {
        return 'id';
    }
}

error

undefined index: id

Activity icon

Replied to Undefined Index: Id Laravel

Hi @marianomoreyra

Is it correct?

public function uniqueBy()
{
    return 'title';
}
Activity icon

Replied to Undefined Index: Id Laravel

From ProductController.php

public function open(Request $request)
{
    Excel::import(new ProductImport, $request->file);
    return redirect()->route('admin::product.index');
}
Activity icon

Started a new Conversation Undefined Index: Id Laravel

I have a notepad like this

notepad

I want to import in excel

ProductImport.php

public function model(array $row)
{
    return Product::updateOrCreate([
        'id' => $row['id']
    ], [
        'title' => $row['title'] == 'NULL' ? null : $row['title'],
        'slug' => $row['slug'] == 'NULL' ? null : $row['slug'],
        'rootCategoryId' => $row['rootcategoryid'] == 'NULL' ? null : $row['rootcategoryid'],
        'description' => $row['description'] == 'NULL' ? null : $row['description'],
        'full_description' => $row['full_description'] == 'NULL' ? null : $row['full_description'],
        'type' => $row['type'] == 'NULL' ? null : $row['type'],
        'price' => $row['price'] == 'NULL' ? null : $row['price'],
        'is_special' => $row['is_special'] == 'NULL' ? null : $row['is_special'],
        'is_special_started_at' => $row['is_special_started_at'] == 'NULL' ? null : $row['is_special_started_at'],

I see this error.

Jan
11
1 month ago
Activity icon

Started a new Conversation How To Create Mobile Number In Faker

I want to create mobile number faker rand.

for example 09389267856

 'mobile' => '09'.$faker->unique()->randomKey([000000000, 999999999]),

This code add in table like 091 and 090

Jan
10
1 month ago
Activity icon

Started a new Conversation How To Get Request In Laravel Pdf?

In Controller, we write for get request Like this.

For example:

public function index(Request $request)
{
    dd($request()->get('search'));

But how to write for get request in Export Excel

view

<a href="{!! route('admin::users.export-filter') !!}" class="btn btn-success">
    <i class="la la-download"></i>
    Export Filter
</a>

web.php

Route::get('/users/export-filter', 'Admin\[email protected]')->name('users.export-filter');

UserController

public function filter()
{
    return Excel::download(new FilterUserExport(request()->get('search')), 'filter.xlsx');
}

FilterUserExport.php

public function view(): View
{
    dd(request()->get('search'));

I seenull.

And my form is like this demo

form

These are all in one form.

The Export Filter button is a tag.

The Search button is submit.

So, now tell me how to submit this Export Filter with

Jan
09
1 month ago
Activity icon

Replied to Get Request In Laravel Excel

I forget a view.

export.blade.php

<table>
    <thead style="background-color: green; color: skyblue; border: 3px solid #ee00ee">
    <tr>
        <th>name</th>
        <th>email</th>
        <th>mobile</th>
        <th>national_id</th>
        <th>full_description</th>
        <th>thumbnai</th>
    </tr>
    </thead>
    <tbody>
    @foreach($users as $user)
        <tr>
            <td>{{ $user->name }}</td>
            <td>{{ $user->email }}</td>
            <td>{{ $user->mobile }}</td>
            <td>{{ $user->national_id }}</td>
            <td>{{ $user->full_description  }}</td>
            <td>{{ $user->thumbnailId  }}</td>
        </tr>
    @endforeach
    </tbody>
</table>
Activity icon

Replied to Get Request In Laravel Excel

😥😥😥😥

Activity icon

Replied to Get Request In Laravel Excel

UserController.php

public function filter()
{
    return Excel::download(new FilterUserExport(request()->get('search')), 'filter.xlsx');
}

FilterUserExport.php

public $search;

public function __construct($search)
{
    $this->search = $search;
}

/**
 * @return View
 */
public function view(): View
{
    dd(request()->all());

 } 

I see this [].