Getting 500 Internal Error in laravel - laravel

I am new to laravel. I want to fetch the data from database and put it to datatable. This is my html
<div class="tab-pane" id="th_days_client" >
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<i class="material-icons">flag</i>
{{ $title }}
</h4>
<span class="pull-right">
<i class="fa fa-fw fa-chevron-up clickable"></i>
<i class="fa fa-fw fa-times removepanel clickable"></i>
</span>
</div>
<div class="panel-body">
<div class="table-responsive">
<table id="th_days_client_data" class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
The jQuery for this is :
var th_days_client;
$(document).ready(function () {
th_days_client = $('#th_days_client_data').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"columns":[
{"data":"name"},
{"data":"email"},
{"data":"mobile"},
{"data":"actions"}
],
"ajax": "{{ url('client') }}" + ((typeof $('#th_days_client_data').attr('data-id') != "undefined") ? "/" + $('#id').val() + "/" + $('#th_days_client_data').attr('data-id') : "/th_days_client_data")
});
});
controller Function for this is :
public function th_days_client_data(Datatables $datatables)
{
$clientObj = new Client;
$client = $clientObj->get()
->map(function ($client) {
return [
'id' => $client->id,
'name' => $client->first_name.' '.$client->last_name,
'email' => $client->email,
'mobile' => $client->mobile
];
});
return $datatables->collection($client)
->addColumn('actions', '#if(Sentinel::inRole(\'admin\'))
<a href="{{ url(\'client/\' . $id . \'/edit\' ) }}" title="{{ trans(\'table.edit\') }}">
<i class="fa fa-fw fa-pencil text-warning "></i> </a>
#endif
<a href="{{ url(\'client/\' . $id . \'/show\' ) }}" title="{{ trans(\'table.details\') }}" >
<i class="fa fa-fw fa-eye text-primary"></i> </a>
#if(Sentinel::inRole(\'admin\'))
<a href="javascript:void(0)" onclick="deleteClient({{$id}})" title="{{ trans(\'table.delete\') }}">
<i class="fa fa-fw fa-trash text-danger"></i> </a>
#endif')
->removeColumn('id')
->rawColumns(['actions'])->make();
}
My route is
Route::group(['prefix' => 'client'], function () {
Route::get('data', 'Users\ClientsController#data');
Route::get('pending_client_data', 'Users\ClientsController#pending_client_data');
Route::get('th_days_client_data', 'Users\ClientsController#th_days_client_data');
Route::get('{client}/edit', 'Users\ClientsController#edit');
Route::post('{client}/update', 'Users\ClientsController#update');
Route::get('{client}/show', 'Users\ClientsController#show');
Route::get('{client}/delete', 'Users\ClientsController#delete');
});
When I am running this then I am getting 500 Internal Error. When I go to laravel.log file then the error is :
[2018-08-01 08:59:27] local.ERROR: Method [th_days_client_data] does not exist on [App\Http\Controllers\Users\ClientsController]. {"exception":"[object] (BadMethodCallException(code: 0): Method [th_days_client_data] does not exist on [App\\Http\\Controllers\\Users\\ClientsController]. at /var/www/webroot/ROOT/files/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:68)
How can I solve this ?

Related

live.ERROR: Trying to get property 'title' of non-object (View: C:\xampp\htdocs\core\resources\views\user\signal-all.blade.php)

ERROR: Trying to get property 'title' of non-object (View: C:\xampp\htdocs\core\resources\views\user\signal-all.blade.php)
Dear, help me please, I can't find the error, it was working fine.
signal-all.blade.php
#extends('layouts.user')
#section('content')
<div class="page-body">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h5>Historial - Ideas de Trading</h5>
<div class="card-header-right">
<ul class="list-unstyled card-option">
<li><i class="fa fa-chevron-left"></i></li>
<li><i class="fa fa-window-maximize full-card"></i></li>
<li><i class="fa fa-minus minimize-card"></i></li>
<li><i class="fa fa-times close-card"></i></li>
</ul>
</div>
</div>
<div class="card-block">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="sample_1">
<thead>
<tr>
<th>#</th>
<th>Fecha</th>
<th>Titulo</th>
<th>Mercado - Par - Tipo</th>
<th>TF - Estado</th>
<th>Acción</th>
</tr>
</thead>
<tbody>
#php $p = 0 #endphp
#if (\Illuminate\Support\Facades\Auth::user()->expire_time != 1 and \Carbon\Carbon::parse(\Illuminate\Support\Facades\Auth::user()->expire_time)->isPast())
<tr>
<td colspan="7"><h6 class="text-center">Su plan esta expirado, actualice su plan Actualizar Plan</h6></td>
</tr>
#elseif (\Illuminate\Support\Facades\Auth::user()->plan_status == 0)
<tr>
<td colspan="7"><h6 class="text-center">Tablero de señales desactivado. PAGO PENDIENTE</h6></td>
</tr>
#else
#php $p = 0 #endphp
#foreach($signal as $k => $p)
<tr>
<td>{{ $k + $signal->firstItem() }}</td>
<td>{{\Carbon\Carbon::parse($p->created_at)->format('d/m/Y - h:i:s A')}}</td>
<td>{{ $p->signal->title }}</td>
<td>{{ $p->signal->asset->name }} - {{ $p->signal->symbol->name }} - {{ $p->signal->type->name }}</td>
<td>{{ $p->signal->frame->name }} - {{ $p->signal->status->name }}</td>
<td>
<i class="fa fa-eye"></i> Ver
</td>
</tr>
#endforeach
#endif
</tbody>
</table>
</div>
#if ($p)
{{$signal->links('basic.pagination')}}
#endif
</div>
</div>
</div>
</div>
</div>
#endsection
I also add layouts.user.php
#php
$planId = Auth::user()->plan_id;
$allSignal = App\SignalPlan::wherePlan_id($planId)->count();
#endphp
<div class="pcoded-main-container">
<div class="pcoded-wrapper">
<nav class="pcoded-navbar">
<div class="sidebar_toggle"><i class="icon-close icons"></i></div>
<div class="pcoded-inner-navbar main-menu">
<div class="pcoded-navigation-label">Panel de Control</div>
<ul class="pcoded-item pcoded-left-item">
<li class="{{ Request::is('user-dashboard') ? 'active' : '' }}">
<a href="{{ route('user-dashboard') }}">
<span class="pcoded-micon"><i class="ti-home"></i><b>D</b></span>
<span class="pcoded-mtext">Inicio</span>
<span class="pcoded-mcaret"></span>
</a>
</li>
</ul>
<div class="pcoded-navigation-label">Ideas de Comercio</div>
<ul class="pcoded-item pcoded-left-item">
<li class="{{ Request::is('user/all-signal') ? 'active' : '' }}">
<a href="{{ route('user-all-signal') }}">
<span class="pcoded-micon"><i class="ti-stats-up"></i><b>D</b></span>
<span class="pcoded-mtext">Señales</span>
<span class="pcoded-badge label label-primary ">{{ $allSignal }}</span>
<span class="pcoded-mcaret"></span>
</a>
</li>
</ul>
<div class="pcoded-navigation-label">Administrar Ganancias</div>
<ul class="pcoded-item pcoded-left-item">
<li class="">
<a href="{!! route('logout') !!}" onclick="event.preventDefault();document.getElementById('logout-form').submit();">
<span class="pcoded-micon"><i class="ti-share-alt"></i><b>D</b></span>
<span class="pcoded-mtext">Salir</span>
<span class="pcoded-mcaret"></span>
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</div>
</nav>
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
#if($errors->any())
#foreach ($errors->all() as $error)
<div class="alert alert-warning icons-alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<i class="icofont icofont-close-line-circled"></i>
</button>
<p>{!! $error !!}</p>
</div>
#endforeach
#endif
#yield('content')
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#if(Auth::user()->plan_status == 1 and Auth::user()->plan->telegram_status == 1)
{!! $basic->chat !!}
#endif
<script>
#if(Session::has('message'))
var type = "{{ Session::get('type', 'info') }}";
switch(type){
case 'info':
toastr.info("{{ Session::get('message') }}");
break;
case 'warning':
toastr.warning("{{ Session::get('message') }}");
break;
case 'success':
toastr.success("{{ Session::get('message') }}");
break;
case 'error':
toastr.error("{{ Session::get('message') }}");
break;
}
#endif
</script>
#yield('scripts')
Controller
public function AllSignal()
{
$data['page_title'] = 'All Signal';
$data['signal'] = SignalPlan::wherePlan_id(Auth::user()->plan_id)->orderBy('id','desc')->paginate(10);
return view('user.signal-all',$data);
}
when I try to execute it throws ERROR: Trying to get property 'title' of non-object
and use plan_status == 1 It works perfect
The syntax of foreach($signal as $k => $p) means, for each element in the array of $signal as a key value pair, which means $p already represents a single $signal object from the array, and $k is the array index. Within a single object of $singal, you have the property title. In order to refer to that attribute, you just need to do $p->title. If you are unsure, you could perform a dd($signal) or a dd($p) somewhere on your blade to verify what it contains

How to get id of slider for get slider_group?

I have two tables sliders and slider_group.
In my controller in create function in laravel, I want the get the id that shows in browser show when I browse it shows like this.
http://localhost:8000/admin/sliders/create/21
blade
<a href="{{ route('admin::sliders.create', ['groupId', $sliderGroup->id]) }}" class="mr-1">
Now how to get the id of slider_group table to group_id of requisitions.
<tbody>
#foreach($sliderGroups as $sliderGroup)
<tr>
<td class="text-truncate">
<i class="la la-dot-circle-o success font-medium-1 mr-1"></i>
{{ $sliderGroup->id }}
</td>
<td class="text-wrap">
{{ $sliderGroup->title }}
</td>
<td class="text-wrap">
{{ getShamsiDate($sliderGroup->created_at) }}
</td>
<td>
<div class="row">
<a href="{{ route('admin::sliders.create', ['groupId', $sliderGroup->id]) }}" class="mr-1">
<i class="la la-plus text-grey text-shadow-custom font-medium-4 font-weight-normal"></i>
</a>
<a href="{{ route('admin::slider-groups.edit', $sliderGroup->id) }}" class="mr-1">
<i class="ft-edit text-grey text-shadow-custom font-medium-4 font-weight-normal"></i>
</a>
<form action="{{ route('admin::slider-groups.destroy', $sliderGroup) }}" method="post" #submit.prevent="confirmDelete">
#method('delete')
#csrf
<button type="submit" class="btn btn-default p-0">
<i class="ft-trash-2 text-grey font-medium-5 font-weight-normal"></i>
</button>
</form>
</div>
</td>
</tr>
#endforeach
</tbody>
I get this in address bar like this
http://localhost:8000/admin/sliders/create?groupId&3
It has an error.
404 | Not Found
Controller
public function index(Request $request)
{
if ($request->search) {
$sliderGroups = SliderGroup::search($request->search)->paginate(30);
} else {
$sliderGroups = SliderGroup::paginate(30);
}
if ($sliderGroups->count() == 0 && $request->search ) {
msg()->warning('it is not found.');
}
return view('slider::admin.groups.index', compact('sliderGroups'));
}
web.php
Route::group([
'prefix' => 'admin',
'as' => 'admin::',
], function() {
Route::resource('sliders', 'Admin\SliderController');
Route::resource('slider-groups', 'Admin\SliderGroupController');
});

Failed to load excel\laravel-excel

I want to export only filtered data in view blade. I am using Laravel 7 and maatwebsite/excel 3.1 and PHP 7.4.2.
I went through the documentation and applied this:
View
<a href="{!! route('users.export-filter') !!}" class="btn btn-success">
<i class="la la-download"></i>
Export Filter
</a>
web.php
Route::get('/users/export-filter', 'Admin\UserController#filter')->name('users.export-filter');
UserController.php
public function filter()
{
return Excel::download(new FilterUserExport, 'filter.xlsx');
}
FilterUserExport.php
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use Modules\User\Entities\User;
use Illuminate\Contracts\View\View;
class FilterUserExport implements FromView, ShouldAutoSize, WithEvents
{
/**
* #return View
*/
public function view(): View
{
$users = app(User::class)->newQuery();
if ( request()->has('search') && !empty(request()->get('search')) ) {
$search = request()->query('search');
$users->where(function ($query) use($search) {
$query->where('first_name', 'LIKE', "%{$search}%")
->orWhere('last_name', 'LIKE', "%{$search}%")
->orWhere('email', 'LIKE', "%{$search}%")
->orWhere('mobile', 'LIKE', "%{$search}%");
});
}
return view('users.index', compact('users'));
}
/**
* #return array
*/
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
}
index.blade.php
#extends("admin-panel.layouts.master")
#section("content")
<div class="content-body">
<section class="grid-with-inline-row-label" id="grid-with-inline-row-label">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">
<a data-action="collapse">
<i class="ft-plus mr-1"></i>
ثبت فیلتر
</a>
</h4>
<a class="heading-elements-toggle"><i class="ft-align-justify font-medium-3"></i></a>
<div class="heading-elements">
<ul class="list-inline mb-0">
<li><a data-action="collapse"><i class="ft-plus"></i></a></li>
<li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
<li><a data-action="expand"><i class="ft-maximize"></i></a></li>
<li><a data-action="close"><i class="ft-x"></i></a></li>
</ul>
</div>
</div>
<div class="card-content collapse #if( $errors->any() ) show #endif">
<div class="card-body">
<form action="{!! route('admin::users.index') !!}" method="get">
<div class="form-body">
<div class="row">
<div class="col-6 form-group">
<label for="search">جستجو</label>
<input type="text" name="search" id="search" class="form-control"
placeholder="جستجو..."
aria-label="جستجو" value="{{ request()->query('search') }}">
</div>
<div class="col-6 form-group">
<label for="user_type">گروه کاربری</label>
<select id="user_type" name="user_type" class="form-control">
<option value="" {{ (request()->query('user_type') == '')? "selected" : "" }}>-</option>
<option value="is_special" {{ (request()->query('user_type') == 'is_special')? "selected" : "" }}>کاربر ویژه</option>
<option value="is_user" {{ (request()->query('user_type') == 'is_user')? "selected" : "" }}>کاربر عادی</option>
<option value="is_admin" {{ (request()->query('user_type') == 'is_admin')? "selected" : "" }}>مدیریت سیستم</option>
</select>
</div>
<div class="col-6 form-group">
<label for="target">فیلتر کاربران</label>
<select id="target" name="target" class="form-control">
<option value="" {{ (request()->query('target') == '')? "selected" : "" }}>-</option>
<option value="active" {{ (request()->query('target') == 'active')? "selected" : "" }}>کاربر ویژه</option>
<option value="orderedAtLeastOnce" {{ (request()->query('target') == 'orderedAtLeastOnce')? "selected" : "" }}>کاربر عادی</option>
<option value="orderedInLastMonth" {{ (request()->query('target') == 'orderedInLastMonth')? "selected" : "" }}>مدیریت سیستم</option>
<option value="neverOrdered" {{ (request()->query('target') == 'neverOrdered')? "selected" : "" }}>مدیریت سیستم</option>
</select>
</div>
<div class="col-md-6 form-group">
<label for="categoryId">دسته بندی</label>
{!! Form::select('categoryId', \Modules\Category\Entities\Category::whereNull('parentId')->get()->pluck('title', 'id')->toArray(), null, [
'class' => 'form-control',
'id' => 'categoryId',
'placeholder' => 'انتخاب دسته بندی',
]) !!}
</div>
</div>
<div class="d-flex justify-content-between form-actions pb-0">
<div>
<button type="submit" class="btn btn-primary">ارسال <i class="ft-send position-right"></i>
</button>
<button type="reset" class="btn btn-warning">ریست <i class="ft-refresh-cw position-right"></i>
</button>
</div>
<div>
<a href="{!! route('admin::users.export-excel') !!}" class="btn btn-success">
<i class="la la-download"></i>
صادر
</a>
<a href="{!! route('admin::users.export-filter') !!}" class="btn btn-success">
<i class="la la-download"></i>
Export Filter
</a>
<a href="{!! route('admin::users.export-special-excel') !!}" class="btn btn-success">
<i class="la la-download"></i>
صدور کاربران ویژه
</a>
<a href="{!! route('admin::users.import-excel') !!}" class="btn btn-primary">
<i class="la la-cloud-download"></i>
آپلود
</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div id="recent-transactions" class="col-xl-12 col-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-md">
<div class="row justify-content-between align-items-center mr-md-1 mb-1">
<div class="col-sm">
<h4 class="card-title mb-2 mb-sm-0">فهرست کاربران</h4>
</div>
</div>
</div>
<div class="col-auto">
<a href="{!! route('admin::users.create') !!}" class="btn btn-info">
<i class="la la-plus"></i>
ایجاد کاربر جدید
</a>
</div>
</div>
</div>
<div class="card-content">
#if( $users->count() > 0 )
#includeWhen( Module::find('notification') && request()->has('search'), 'user::admin.users._notification' )
<div class="table-responsive">
<table id="recent-orders" class="table table-hover table-xl mb-0">
<thead>
<tr>
<th class="border-top-0"># شناسه</th>
<th class="border-top-0">نام و نام خانوادگی</th>
<th class="border-top-0">موبایل</th>
{{-- <th class="border-top-0">ایمیل</th>--}}
<th class="border-top-0">کد ملی</th>
<th class="border-top-0">مدیر</th>
<th class="border-top-0">وضعیت</th>
<th class="border-top-0">ویژه</th>
<th class="border-top-0">آخرین ورود</th>
<th class="border-top-0">عملیات</th>
</tr>
</thead>
<tbody>
#foreach($users as $user)
<tr>
<td class="text-truncate">
<i class="la la-dot-circle-o success font-medium-1 mr-1"></i>
{{ $user->id }}
</td>
<td class="text-wrap">
{{ $user->first_name.' '.$user->last_name }}
</td>
<td class="text-wrap">
{{ $user->mobile }}
</td>
{{--<td class="text-wrap">
{{ $user->email }}
</td>--}}
<td class="text-wrap">
{{ $user->national_id }}
</td>
<td class="text-wrap">
#if( $user->is_admin )
<i class="ft-check-circle text-success"></i>
#else
<i class="ft-x-circle text-danger"></i>
#endif
</td>
<td class="text-wrap">
#if( !$user->disabled_at )
<i class="ft-check-circle text-success"></i>
#else
<i class="ft-x-circle text-danger"></i>
#endif
</td>
<td class="text-wrap">
#if( $user->is_special_user == 1 )
<i class="ft-check-circle text-success"></i>
#else
<i class="ft-x-circle text-danger"></i>
#endif
</td>
<td class="text-wrap">
#if( $user->last_login_at )
{{ getShamsiDate($user->last_login_at) }}
#else
—
#endif
</td>
<td>
<div class="row flex-nowrap">
<a href="{{ route('admin::users.show', $user) }}" class="mr-1">
<i class="ft-eye text-grey text-shadow-custom font-medium-5 font-weight-normal"></i>
</a>
<a href="{{ route('admin::users.edit', $user) }}" class="mr-1">
<i class="ft-edit text-grey text-shadow-custom font-medium-4 font-weight-normal"></i>
</a>
<form action="{{ route('admin::users.destroy', $user) }}"
method="post"
#submit.prevent="confirmDelete">
#method('delete')
#csrf
<button type="submit" class="btn btn-default p-0">
<i class="ft-trash-2 text-grey font-medium-5 font-weight-normal"></i>
</button>
</form>
</div>
</td>
</tr>
#endforeach
</tbody>
</table>
<div class="pagination-flat">
{{ $users->links() }}
</div>
</div>
#else
<div class="text-center my-2">
<p>نتیجه‌ای برای نمایش وجود ندارد.</p>
</div>
#endif
</div>
</div>
</div>
</div>
</section>
</div>
#endsection
I get this error
The export submit button is sending everything to Excel. How do I make it to send only the filtered data. Thanks
You need to get rid of the other HTML in your view such as forms, inputs, and buttons. Keep the view only to a minimum of the table that needed for your Excel.

fail to show allert " No data" when data is does not in database

i am using laravel 5.4 ,, i use filter by serial number, i want to when the serial number is not save in database, show the allert "no data" , but when i filter data serial number is not save to database, the page is not show the allert,,
this is my blade..
#extends('layouts.master')
#section('content')
......................................
<div class="panel panel-default">
#if (!$instrumentType->instruments->isEmpty())
<table class="table">
#foreach ($instruments as $instrument)
<tr>
<td>
Serial Number : {{ $instrument->serial_number }}
#if($instrument->customer !== NULL)
<div class="text-muted"><i class="fa fa-hospital-o" aria-hidden="true"></i> {{ $instrument->customer->name }}</div>
#endif
#if($instrument->contractType !== NULL)
<div class="text-muted"><i class="fa fa-compress" aria-hidden="true"></i> {{ $instrument->contractType->name }}</div>
#endif
</td>
<td>
<div class="pull-right">
<a type="button" href="{{ route('instrument.edit', ['instrumentType' => $instrumentType->id, 'instrument' => $instrument->id]) }}"
class="btn btn-success ">
<i class="fa fa-pencil"></i> Edit
</a>
#if($instrument->customer == NULL || $instrument->contractType == NULL)
<a href="{{ route('instrument.destroy', ['instrumentType' => $instrumentType->id, 'instrument' => $instrument->id]) }}"
data-method="delete" data-confirm="" class="btn btn-danger">
<i class="fa fa-trash"></i> <span class="hidden-xs">Delete</span>
</a>
#endif
</div>
</td>
</tr>
#endforeach
</table>
<div class="paginator text-center">{{ $instruments->links() }}</div>
#else
<div class="panel-body">
<div class="alert alert-warning text-center">No data.</div>
</div>
#endif
</div>
#endsection
.
you can get count of array with :
count($instrumentType->instruments)
add this code as your statement :
#if(count($instrumentType->instruments))
//
#else
//
#endif

Unable to show data from database in Laravel after inserting data into database

I was able to insert data into database in Laravel but when I was trying to show the data in a tabular form I couldn't - it was displaying Route [stock_edit] not defined. (View: C:\wamp\www\pump\core\resources\views\dashboard\stock-show.blade.php)
Like I said in my quetion yesterday, I am new to Laravel and I am yet to understand the environment. I have been on this for the past 48 hours searching for help online but couldn't find a satisfactory ones
Here is my stock-show.blade.php
#extends('layouts.dashboard')
#section('title', 'All Stock')
#section('content')
#if(count($stock))
<div class="row">
<div class="col-md-12">
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption font-dark">
</div>
<div class="tools"> </div>
</div>
<div class="portlet-body">
<table class="table table-striped table-bordered table-hover" id="sample_1">
<thead>
<tr>
<th>ID#</th>
<th>Product Name</th>
<th>Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>
#foreach($stock as $p)
<tr>
<td>{{ $p->id }}</td>
<td>{{ $p->name }}</td>
<td>{{ $p->price }} </td>
<td>
<i class="fa fa-edit"></i> EDIT
<button type="button" class="btn btn-danger btn-sm delete_button"
data-toggle="modal" data-target="#DelModal"
data-id="{{ $p->id }}">
<i class='fa fa-times'></i> DELETE
</button>
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
</div><!-- ROW-->
<div class="text-center">
{!! $stock->render() !!}
</div>
#else
<div class="text-center">
<h3>No Data available</h3>
</div>
#endif
<!-- Modal for DELETE -->
<div class="modal fade" id="DelModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel"> <i class='fa fa-trash'></i> Delete !</h4>
</div>
<div class="modal-body">
<strong>Are you sure you want to Delete ?</strong>
</div>
<div class="modal-footer">
<form method="post" action="{{ route('stock_delete') }}" class="form-inline">
{!! csrf_field() !!}
{{ method_field('DELETE') }}
<input type="hidden" name="id" class="abir_id" value="0">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger">DELETE</button>
</form>
</div>
</div>
</div>
</div>
#endsection
#section('scripts')
<script>
$(document).ready(function () {
$(document).on("click", '.delete_button', function (e) {
var id = $(this).data('id');
$(".abir_id").val(id);
});
});
</script>
#endsection
and this is the DashboardController.php
//Stocks
public function createStock()
{
$data['site_title'] = $this->site_title;
$data['page_title'] = "Create Stock";
//$data['currency'] = Currency::all();
return view('dashboard.stock-create',$data);
}
public function storeStock(Request $request)
{
$this->validate($request,[
'name' => 'required|unique:stocks,name',
'price' => 'required',
//'currency_id' => 'required'
]);
try {
$stock = Input::except('_method','_token');
Stock::create($stock);
session()->flash('message', 'Stock Create Successfully.');
Session::flash('type', 'success');
return redirect()->back();
} catch (\PDOException $e) {
session()->flash('message', 'Some Problem Occurs, Please Try Again!');
Session::flash('type', 'danger');
return redirect()->back();
}
}
public function showStock()
{
$data['site_title'] = $this->site_title;
$data['page_title'] = "All Stock";
$data['stock'] = Stock::orderBy('id','ASC')->paginate(100);
return view('dashboard.stock-show',$data);
}
public function editStock($id)
{
$data['stock'] = Stock::findOrFail($id);
$data['site_title'] = $this->site_title;
$data['page_title'] = 'Edit Product';
$data['stock'] = Stock::all();
return view('dashboard.stock-edit',$data);
}
public function updateStock(Request $request,$id)
{
$stocks = Stock::findOrFail($id);
$this->validate($request,[
'name' => 'required|unique:stocks,name,'.$stocks->id,
'price' => 'required',
//'currency_id' => 'required',
]);
try {
$stock = Input::except('_method','_token');
$stocks->fill($stock)->save();
session()->flash('message', 'Stock Updated Successfully.');
Session::flash('type', 'success');
return redirect()->back();
} catch (\PDOException $e) {
session()->flash('message', 'Some Problem Occurs, Please Try Again!');
Session::flash('type', 'danger');
return redirect()->back();
}
}//Stocks End
And lastly the route.php
/* Stock Route List */
Route::get('stock-create',['as'=>'stock-create','uses'=>'DashboardController#createStock']);
Route::post('stock-create',['as'=>'stock-store','uses'=>'DashboardController#storeStock']);
Route::get('stock-show',['as'=>'stock-show','uses'=>'DashboardController#showStock']);
Route::get('stock-edit/{id}',['as'=>'stock-edit','uses'=>'DashboardController#editStock']);
Route::put('stock-edit/{id}',['as'=>'stock-update','uses'=>'DashboardController#updateStock']);
You have a typo in your code,
change stock_edit to stock-edit in your view

Resources