Neeraj1005

Member Since 1 Year Ago

INDIA

Experience Points
36,320
Total
Experience

3,680 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
159
Lessons
Completed
Best Reply Awards
2
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 8
36,320 XP
Apr
26
2 weeks ago
Activity icon

Replied to Image Upload Not Working

i did the same for image uploading but foreach loop is not working.... Is there any other things to do...?

    if ($request->hasFile('images')) {

            foreach ($request->file('images') as $photo) {
                dd($photo); // this is also not working 
                $path_url = $photo->storePublicly('rfqs', 'public');
                $storedData->images()->create([
                    'file_name' => $photo->getClientOriginalName(),
                    'mime_type' => $photo->getMimeType(),
                    'file_path' => $path_url,
                ]);
            }
        }
Activity icon

Replied to Image Upload Not Working

@tray2 If I do for this single image it is working but for multiple image it is not working.

   if ($request->hasFile('images')) {
            // foreach (request('images') as $photo) {
                $path_url = request('images')->storePublicly('rfqs', 'public');
                $storedData->images()->create([
                    'file_name' => request('images')->getClientOriginalName(),
                    'mime_type' => request('images')->getMimeType(),
                    'file_path' => $path_url,
                ]);
            // }
        }
Activity icon

Replied to Image Upload Not Working

@tray2 Basically I'm testing this API on postman. How to add encytype..?

Activity icon

Started a new Conversation Image Upload Not Working

I'm trying to create an API to store the value but my image store is not working, For image upload, I'm using polymorphic table with hasMany relations. But I don't why it is not storing. plz check my code what i did wrong...? THis is my api controller

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'product_name' => 'required',
            'product_category_id' => 'required|not_in:0',
            'sub_category_id' => 'required|not_in:0',
            'company_id' => 'required|not_in:0',
            'product_quantity' => 'nullable|numeric',
            'unit_id' => 'nullable|numeric|not_in:0',
            'purchase_price' => 'nullable',
            'city' => 'nullable|string|max:255',
            // 'isChecked' => 'required|accepted',
            'details' => 'required|string|min:5',
            'images.*' => 'mimes:jpg,jpeg,png,bmp,gif,svg,webp,pdf,docx|max:1024',
        ]) + [
            'user_id' => auth()->user()->id,
        ];

        // $storedData = auth()->user()->rfqs()->create($validatedData);
        $storedData = Rfq::create($validatedData);

        if ($request->hasFile('images')) {

            foreach ($request->file('images') as $photo) {
                dd($photo); // this is also not working 
                $path_url = $photo->storePublicly('rfqs', 'public');
                $storedData->images()->create([
                    'file_name' => $photo->getClientOriginalName(),
                    'mime_type' => $photo->getMimeType(),
                    'file_path' => $path_url,
                ]);
            }
        }

        $response =  new RfqResource($storedData);

        return response()->json(['status' => 'success', 'data' => $response]);

    }

THis direct show me the output....

Apr
05
1 month ago
Activity icon

Replied to Laravel 8 Email Not Working On Live But Working On Local & Other Server

@nayana you have to set your mail encryption as well

MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.com // YOUR MAIL DOMAIN
MAIL_PORT=465
[email protected] // YOUR MAIL USERNAME
MAIL_PASSWORD='heremypassword'    // your password
MAIL_ENCRYPTION=ssl  // your encryption ssl or tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
Activity icon

Replied to Swift_TransportException

my password and user credential are correct...I think in my case some server site problem because in my cpanel mail is also not working

Activity icon

Started a new Conversation Swift_TransportException

Swift_TransportException
Failed to authenticate on SMTP server with username "[email protected]" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data ". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data ".

In my project I'm getting this error. can anyone tells me what was the reason..?

env

MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=heremypassword'
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
Mar
30
1 month ago
Activity icon

Replied to Show User Id In A P Tag

@usmanbasharmal I think you forgot to import use App\User

<?php

namespace App\Http\Livewire\Backend;
use App\Domains\Auth\Models\User;
use Livewire\Component;

#import this

use App\User; 

Feb
06
3 months ago
Activity icon

Replied to Connection Could Not Be Established With Host Smtp.mailtrap.io [php_network_getaddresses: Getaddrinfo Failed: No Such Host Is Known. #0]

After adding the mail credential just clear the cache/config using this simple command

php artisan optimize

OR

php artisan config:clear

php artisan cache:clear
Feb
01
3 months ago
Activity icon

Replied to User Relationships Based On Role

@martinbean Yes, I agreed.

But what about Role management? I think @kevinv can use this type of scenario for multiple users instead of creating different-2 tables.

Activity icon

Started a new Conversation Livewire/sortable Package.

In my project I've used this package and dragging is working but Now the major part is how to save data in the backend. Means while dragging the element one group to another than status_id would be updated in the tasks table. How can I achieve this...? please check this my code livewire blade component code

<div>
    @include('includes.livewire-message')
    <div class="row" wire:sortable-group="updateTaskOrder">
        @foreach($taskKanban as $status)
            <div class="col-md-4" wire:key="group-{{ $status->id }}" wire:sortable-group.item-group="{{ $status->id }}">
                <div class="card rounded-pill bg-gradient">
                    <div class="card-body">
                        <span class="fs-5 fw-bold p-2">{{ $status->name }} {{ $status->id }}</span><span
                            class="badge position-absolute top-50 end-0 translate-middle bg-pink rounded-pill p-2">{{ count($status->tasks) }}</span>
                    </div>
                </div>
                @foreach($status->tasks as $task)
                    <div class="card br-10 m-2" wire:key="task-{{ $task->id }}" wire:sortable-group.item="{{ $task->id }}">
                        <div class="card-body">
                            <img class="profile-xl float-sm-end border" src="{{ $task->assignTo->userProfile() }}">
                            <h5 class="text-black m-0 fs-6 fw-bold">
                                <a wire:click.prevent="viewTask({{ $task->id }})" href="#" data-bs-toggle="modal"
                                    data-bs-target="#viewTask">{{ $task->assignTo->name }}</a>
                            </h5>
                            <p class="text-dark-gray m-0 fst-italic">Department: {{ $task->department->name }}
                            </p>
                            <p class="text-gray m-0 w-90">
                                Task Title: {{ $task->name }}
                                <a href="#" class="gray"><i class="bi bi-paperclip p-1 gray"></i></a>
                            </p>
                            <span
            class="text-pink mt-1 float-start">{{ $task->created_at->calendar().' '.$task->created_at->isoFormat('Do Y') }}</span>
                            <div class="float-end">
                                @hasrole('admin')
                                    <a wire:click.prevent="editTask({{ $task->id }})" href="#" class="gray"
                                        data-bs-toggle="modal" data-bs-target="#updateTaskModal">
                                        <i class="bi bi-pencil-square"></i>
                                    </a>
                                    <a wire:click.prevent="putTaskOnTrash({{ $task->id }})"
                                        onclick="confirm('Confirm delete?') || event.stopImmediatePropagation()"
                                        href="#" class="gray"><i class="bi bi-trash p-2"></i></a>
                                @endhasrole
                                <a href="#" data-bs-toggle="modal" data-bs-target="#comment" class="gray">
                                    <i class="bi bi-chat-right-text"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
        @endforeach
    </div>
</div>

livewire component

<?php

namespace App\Http\Livewire\Dashboard;

use App\Models\Task;
use App\Models\Status;

class Kanban extends Component
{
    public $taskKanban;

    public function updateTaskOrder($orderIds)
    {
        ray($orderIds);
    }

    public function render()
    {
        ray()->clearAll();
        
        $this->taskKanban = Status::with(['tasks' => function($q){
            return $q->where('assign_to', auth()->user()->id)->isActive()->latest();
        }])->get();
        
        return view('livewire.dashboard.kanban');
    }
}

Output screen

image

dd() result

image

Jan
30
3 months ago
Activity icon

Replied to Generate A Last 7 Days Weekly Report In Mysql

@kundefine @madyson you can use carbon subDays method in laravel.

$users = YourModel::where( 'created_at', '>', Carbon::now()->subDays(7))
           ->get();

give it try as well

Jan
27
3 months ago
Activity icon

Awarded Best Reply on Sync() Add Additional Column Value In Pivot Table

Solved

$task->assignTo()->sync([
            $this->assign_to => [
                'status_id' => 1,
            ],
        ]);
Activity icon

Replied to Sync() Add Additional Column Value In Pivot Table

Solved

$task->assignTo()->sync([
            $this->assign_to => [
                'status_id' => 1,
            ],
        ]);
Activity icon

Started a new Conversation Sync() Add Additional Column Value In Pivot Table

In my project I have User,Task,Status model. and I have pivot table which stores task_id, user_id, status_id. Then problem is now if I sync or store the value status_id is not stored can anyone tells me how to store 3rd value in pivot table.

// IN Task Model I have relationship like
    public function assignTo()
    {
        return $this->belongsToMany(User::class,'task_user','task_id','user_id');
    }

code

    $task = auth()->user()->tasks()->create([
            'name' => $this->title,
            'message' => $this->message,
            'department_id' => $this->department_id,
            'deadline_id' => $this->deadline_id,
        ]);

        $task->assignTo()->sync([
            'user_id' => $this->assign_to,
            'status_id' => 1,
            'created_at' => now(),
        ]);
Jan
26
3 months ago
Activity icon

Replied to Retrieve An Input Form The Query String

do you want to get 50 items ? then do this

$todos = $this->user->todos()->take(50)->get(['id', 'title', 'body', 'completed', 'created_by']);
OR
$todos = $this->user->todos()->paginate(50);

return response()->json($todos->toArray());

If you are creating an API user Laravel API https://laravel.com/docs/8.x/eloquent-resources#resource-collections technique

Activity icon

Replied to Department, User, Task Assign

okk I'll try this...

Activity icon

Replied to JQuery Reset Selected Option

@www888 Then why you tried this for ajax...? just use simple jquery...for dom changes..

Activity icon

Replied to BelongsToMany With UpdateOrCreate

@eddieace check this link you will get why every time new database record is created... https://stackoverflow.com/a/42696141/8455396

Activity icon

Replied to Department, User, Task Assign

@nimrod Yes for future reference task would be assigned to multiple users... So I have to create another intermediate table now...?

Activity icon

Replied to JQuery Reset Selected Option

so you want to create 3rd level descendent dropdown level..?

Activity icon

Replied to JQuery Reset Selected Option

@www888 what are trying actually...? however, if you change the selectA then there below children selected attribute will be reset..?

Activity icon

Started a new Conversation Department, User, Task Assign

In my project I stuck with some table relationship. Hope anyone can solve my problem to resolve schema relationship between tables...

Basic steps... First Admin login Second He will create a department Third, add users with assign department

Now I'm stucking in fourth point: Fourth, Then after creating user with department He will goes for Creating Task where he create the task. But my questing if user hasMany Tasks then how he would be assign the task?

should I have to create intermediate table assign_task like that because in tasks table there is already a user_id column

tasks table

id
task_name
task_message
slug
department_id
user_id  //this would be user id => created by

How can I implement assign to 
should I have to add another column for assign_id like that and what would be the relationship..Or either should go for another new intermediate table?
Activity icon

Replied to Bootstrap5 ERROR In ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41

@sami.chkeir @devingray_ I solved this issue few days ago... sorry to check this late...

https://popper.js.org/ I run this command and my error solved

npm i @popperjs/core
Jan
23
3 months ago
Activity icon

Started a new Conversation Bootstrap5 ERROR In ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41

ERROR in ./node_modules/bootstrap/dist/js/bootstrap.esm.js 6:0-41
Module not found: Error: Can't resolve '@popperjs/core' in 'C:\laragon\www\tasky\node_modules\bootstrap\dist\js'

webpack compiled with 1 error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nick\AppData\Roaming\npm-cache\_logs21-01-23T14_13_45_627Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nick\AppData\Roaming\npm-cache\_logs21-01-23T14_13_45_776Z-debug.log

I installed fresh laravel project with laravel/ui package. And I installed new bootstrap5 for this project but when I tried to run npm run dev command this send the error. can anyone know how to install bootsrap 5 in laravel 8?

Jan
15
3 months ago
Activity icon

Awarded Best Reply on How Do You Pass Data To A Partial?

@vusumzi Like this In laravel there is no command for viewComposer so you have to manually create viewComposerFile inside App\Http\View\Composers\YourFileNameComposer

Then paste these code inside your composer file

<?php

namespace App\Http\View\Composers;

use Illuminate\View\View;

class YourFileNameComposer
{
    public function __construct()
    {
    }

    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with(
            'notifications', auth()->user()->unreadNotifications,
        );
   	$view->with(
            'unread',auth()->user()->unreadNotifications->count(),
        );
    }
}

Then after Register it into AppServiceProvider like this

 View::composer(
            ['partials._topbar'], 'App\Http\View\Composers\YourFileNameComposer',
        );
Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi Like this In laravel there is no command for viewComposer so you have to manually create viewComposerFile inside App\Http\View\Composers\YourFileNameComposer

Then paste these code inside your composer file

<?php

namespace App\Http\View\Composers;

use Illuminate\View\View;

class YourFileNameComposer
{
    public function __construct()
    {
    }

    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with(
            'notifications', auth()->user()->unreadNotifications,
        );
   	$view->with(
            'unread',auth()->user()->unreadNotifications->count(),
        );
    }
}

Then after Register it into AppServiceProvider like this

 View::composer(
            ['partials._topbar'], 'App\Http\View\Composers\YourFileNameComposer',
        );
Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi you did wrong...

  • First create view composer
  • then write condition under view composer
  • register view composer file inside AppServiceProvider.
Activity icon

Replied to Am I Writing Laravel The Right Way !

it is easy and useful...instead of writing sql queries... eloquent is too much user friendly to write query..... just read the docs and watch tutorial...there are plenty free video course on laravel...just watch...

Activity icon

Replied to Bootstrap4 Datetimepicker

there are several library for this you can checkout these

these two i mostly used...

Activity icon

Replied to How Do You Pass Data To A Partial?

@vusumzi there is two way you can pass data to your partials:

  • using view composer
  • using blade component technique

read on laravel docs...you will get this idea.

Jan
07
4 months ago
Activity icon

Started a new Conversation Create:893 Livewire: The Published Livewire Assets Are Out Of Date See: Https://laravel-livewire.com/docs/installation/

I don't know why a few days ago my project with livewire was working good...But now today suddenly it won't work. It return some error in console.

create:893 Livewire: The published Livewire assets are out of date
 See: https://laravel-livewire.com/docs/installation/

Uncaught TypeError: window.livewire.devTools is not a function
    at create:902

can anyone tells me what was the exact problem

Activity icon

Started a new Conversation Spatie/laravel-ray 1.0.0 Requires Spatie/ray Dev-master -> Satisfiable By Spatie/ray[dev-master].

In my laravel app I'm trying to install https://spatie.be/docs/ray/v1/getting-started/installation-in-laravel ray. But after running the command in terminal it throw me some error. can anyone tells me how to solve this...?

λ composer require spatie/laravel-ray --dev
Using version ^1.0 for spatie/laravel-ray
./composer.json has been updated
Running composer update spatie/laravel-ray
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - spatie/laravel-ray 1.0.0 requires spatie/ray dev-master -> satisfiable by spatie/ray[dev-master].
    - spatie/laravel-ray 1.0.1 requires spatie/ray ^1.0 -> satisfiable by spatie/ray[1.0.0, 1.0.1].
    - spatie/ray[dev-master, 1.0.0, ..., 1.0.1] require symfony/console ^4.2|^5.2 -> found symfony/console[v4.2.0-BETA1, ..., 4.4.x-dev, v5.2.0-BETA1, ..., 5.x-dev] but the package is fixed to v5.1.8 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires spatie/laravel-ray ^1.0 -> satisfiable by spatie/laravel-ray[1.0.0, 1.0.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Did anyone try to install and runs the command spatie/ray. And my Operating system is windows

Activity icon

Replied to Pagination With Search Filter

@usamafiaz Can you show your controller method what query you have executed..?

In your controller if you have query like this

$users = User::search(request('search_input'))->paginate(15);

then appendwithQueryString() after paginate.

$users = User::search(request('search_input'))->paginate(15)->withQueryString();
Activity icon

Replied to How To Pass Id For Update In Laravel

@mrperfectionist Try this technique

const id = $("#ID").val();
const route= "{{ route('admin.department.update')}}";

const updateUrl= route+id;

$.ajax({
   url: updateUrl
});

Or instead of route you can use url: 'your_url'+ id

Jan
05
4 months ago
Activity icon

Started a new Conversation Preg_match(): Delimiter Must Not Be Alphanumeric Or Backslash (View: C:\laragon\www\crm\resources\views\rfq\lists-rfq.blade.php)

In my project I have file upload system with file and image support... In front page I want to perform a query if user has upload an image then image show other wise not show document... So I make a function in model it throw some errro can anyone tell what i did wrong

  protected $fillable = [
        'imageable_id',
        'imageable_type',
        'file_name',
        'mime_type',
        'file_path',
    ];

public function fileType()
    {
        $value = preg_match('image/',$this->mime_type);
        if ($value) {
            return true;
        }
    }
Activity icon

Replied to File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

@snapey should I have to remove image?

'images.*' => 'mimes:jpg,bmp,png,pdf,docx|max:1024'

like this => it is correct way..?

Activity icon

Started a new Conversation File(docx,pdf) And Image(jpeg,png Etc..) Support Validation Laravel

In my form I have a file upload tag....but I want to both type of file upload support such as user can upload pdf,docx,image aswell. Can anyone tell me what validation I have to make...?

This is my validation

$validatedData = $this->validate([
            'product_name' => 'required',
            'images.*' => 'image|max:1024',
        ]);
Activity icon

Replied to How To Add Multiple Foreign Key In Migration File

@aasifkhan is your states/doctors/countries id does contains unsignedInteger type?....check their id types.... and try to use unsignedInteger

$table->unsignedInteger('state_id', 255)->nullable();

Jan
04
4 months ago
Activity icon

Started a new Conversation Bootstrap Modal Descendent Dropdown Not Working

In my project, For storing data I’m using the bootstrap modal. But the problem I faced In my modal that is the descendent dropdown is not working. If I used this wire: ignore method if I removed this wire: ignore method then the modal hides. Can anyone tell me how can I render the dynamic data while using the wire:ignore method. This is my LIvewire component methods

<?php

namespace App\Http\Livewire\Poi;

use App\Poi as AppPoi;
use Livewire\Component;
use App\Tbl_productcategory;
use App\Tbl_product_subcategory;

class Poi extends Component
{
    public $product_name;
    public $user_id;
    public $product_category_id;
    public $sub_category_id;
    public $isActive;
    
    public $subcategories = [];

    public function store()
    {
        $validatedData = $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
        ]);

        $validatedData['user_id'] = auth()->user()->id;

        AppPoi::create($validatedData);

        session()->flash('message', 'Row data successfully created.');

        $this->reset();

    }

    public function render()
    {
        try {
            if (!empty($this->product_category_id)) {
                $this->subcategories = Tbl_product_subcategory::where('procat_id', $this->product_category_id)->get();
            }
            return view('livewire.poi.poi')->with([
                'product_of_interests' => AppPoi::get(),
                'categories' => Tbl_productcategory::has('tbl_product_subcategory')->get(),
            ]);
        } catch (\Throwable $th) {
            dd('catch exception', $th->getMessage());
        }
    }
}

This is my blade component

<div wire:ignore>
    <!-- Modal -->
    <div class="modal fade" id="poiModal" tabindex="-1" aria-labelledby="poiModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="poiModalLabel">Add New</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <form wire:submit.prevent="store">
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="product_name">Product Name</label>
                            <input wire:model="product_name" type="text" class="form-control" id="product_name" placeholder="eg: shoes">
                        </div>
                        <div class="form-group">
                            <label for="product_category_id">Category</label>
                            <select class="form-control required"
                                wire:model="product_category_id" name="product_category_id" id="product_category_id">
                                <option value="0">Select Category</option>
                                @foreach($categories as $cat)
                                    <option value="{{ $cat->procat_id }}">{{ $cat->category }}</option>
                                @endforeach
                            </select>
                        </div>
        
                        <div class="form-group">
                            <label for="sub_category_id">SubCategory</label>
                            <select class="form-control required"
                                wire:model="sub_category_id" name="sub_category_id" id="sub_category_id">
                                <option value="">select subcategory</option>
                                @foreach($subcategories as $subcat)
                                    <option value="{{ $subcat->prosubcat_id }}">{{ $subcat->category }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
Jan
02
4 months ago
Activity icon

Replied to Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

@tisuchi basically I tried the attached for rfqs and images oneToMany relationship table. And user_id is used in rfqs table.

Activity icon

Replied to BelongsToMany Take 1 .

@binggle your relationship is wrong...make proper relationship...as @tisuchi said.

  • cat Model hasMany videos
  • videos Model belongsToMany cats
Activity icon

Replied to Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

@tray2 Ohh! so attach used in only manyTomany case...? Instead of save can I use create also?

Activity icon

Started a new Conversation Call To Undefined Method Illuminate\Database\Eloquent\Relations\MorphMany::attach()

In my laravel project I'm trying to add mulitple image for RFQ table...can anyone tell me what i did wrong. My relationship like: rfq hasMany images AND images belongsTo rfqs This is my livewire method

public function store()
    {
        $validatedData = $this->validate([
            'product_name' => 'required',
            'product_category_id' => 'required|not_in:0',
            'sub_category_id' => 'required|not_in:0',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'nullable',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
            'details' => 'required|string|min:1|max:500',
            'images.*' => 'image|max:1024',
        ]) + [
            'user_id' => auth()->user()->id,
        ];

        $rfqData = Rfq::create($validatedData);

        // if ($this->images) 
        // {
            foreach ($this->images as $photo) {
                $path_url = $photo->storePublicly('rfqs', 'public');

                $rfqData->images()->attach($photo,[
                    'file_name' => $photo->getClientOriginalName(),
                    'file_path' => $path_url,
                ]);
            }
        // }


        session()->flash('message', 'RFQ submitted successfully.');

        $this->reset();
    }
Dec
31
4 months ago
Activity icon

Replied to SQLSTATE[HY000]: General Error: 1366 Incorrect Integer Value: 'on' For Column 'isChecked' At Row 1 (SQL: Insert Into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`

@tisuchi okk I tried it letter but I solve this problem using this conditional statements.

     $validatedData = $request->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'purchase_price' => 'nullable',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
            'details' => 'nullable',
        ])+[
            'user_id' => auth()->user()->id,
        ];

        if (request('isChecked') === 'on') {
            $validatedData['isChecked'] = true;
        }
Activity icon

Started a new Conversation SQLSTATE[HY000]: General Error: 1366 Incorrect Integer Value: 'on' For Column 'isChecked' At Row 1 (SQL: Insert Into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'on' for column 'isChecked' at row 1 (SQL: insert into `rfqs` (`product_name`, `product_category_id`, `sub_category_id`, `product_quantity`, `unit_id`, `city`, `isChecked`, `details`, `user_id`, `updated_at`, `created_at`) values (Watch, 1, 1, 1, 1, Delhi, on, ?, 37, 2020-12-31 11:10:16, 2020-12-31 11:10:16))

Basically this return error for checkbox. In my table isCheckedcolumn is boolean. And I try dd() it return on for isChecked value. Can anyone tells me how return true/false for isChecked? Controller Method

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'product_name' => 'required',
            'product_category_id' => 'required',
            'sub_category_id' => 'required',
            'product_quantity' => 'required',
            'unit_id' => 'required|not_in:0',
            'city' => 'required|',
            'isChecked' => 'required|accepted',
        ])+[
            'details' => $request->details,
            'user_id' => auth()->user()->id,
        ];

        Rfq::create($validatedData);

        return redirect()->withMessage('RFQ submitted successfully.');
    }
Activity icon

Replied to How To Add Middleware Auth Condition For Submit Form In Livewire Component

@tray2 ok..but I put the login route then how can I redirect back at the same form...? Because I did try this but it return to me a dashboard page... Should I have to chage redirectRoute...?