Category : laravel-4

I need the column date and digits to concatenate. The date should be YY-mm format and the digits should have a leading zero. Example output 21-09-0001 How to do it in WHERE FUNCTION laravel eloquent? like this. I found this on the internet example: public function scopeFindDVNumber($query,$name) { $query->where(DB::raw( "REPLACE( COALESCE(name_first,”),’ ‘, COALESCE(name_middle,”),’ ‘, COALESCE(name_last,”) ..

Read more

public function create($projectId) { $project = Project::find($projectId); $invoiceData[‘company_data’] = common::getCompanyData($project->billing_country); $invoiceData[‘project’] = $project; // IF INVOICE COMPANY From ADDRESS & To ADDRESS ARE FROM INDIA THEN GST WILL BE ADDED $taxes_billing_country = ‘Dubai’; $taxes_alter = ”; if( $invoiceData[‘company_data’][‘billing_country’] == ‘India’ && $invoiceData[‘project’][‘country’] == ‘India’ ) { $taxes_billing_country = ‘India’; // IF INVOICE COMPANY From ADDRESS ..

Read more

After downloading the latest php and installing composer. then installed laravel using the command composer global require laravel/installer Changed current directory to C:/Users/User/AppData/Roaming/Composer Using version ^4.2 for laravel/installer ./composer.json has been created Running composer update laravel/installer Loading composer repositories with package information Updating dependencies Lock file operations: 13 installs, 0 updates, 0 removals – Locking ..

Read more

I’m beginner in Laravel and when I’m trying to use Controller I’m getting this error IlluminateContractsContainerBindingResolutionException Target class [PostsController] does not exist. http://127.0.0.1:8000/posts routes directory contain web.php to route and there I’m using Route::get(‘/posts’, ‘[email protected]’); to redirect to the class PostsController <?php namespace AppHttpControllers; use IlluminateHttpRequest; class PostsController extends Controller { public function index() { ..

Read more

I have a laravel and angular app when i run angular app i’m getting following error: Access to XMLHttpRequest at ‘http://localhost/project/public/api/register’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. I already have CORS middleware: <?php namespace ..

Read more

class Order extends Model { protected $appends = [‘test’]; public function orderItems() { return $this->hasMany(‘AppOrderItem’); } public function getTestAttribute() { return $this->orderItems->first()->id; } } class OrderItem extends Model { protected $appends = [‘test’]; public function order() { return $this->belongsTo(‘AppOrder’); } public function getTestAttribute() { return $this->order->id; } } Given models with above definitions, when I ..

Read more

I have a expiry_date (type=date) column in my table $currentDate = date(‘Y-m-d’); $Data = Post::whereDate(‘expiry_date’,'<=’,$currentDate)->where([‘status’ => ‘active’])->orWhere([‘p_id’ => 3])->select(‘id’,’title’,’status’,’p_id’,’expiry_date’)->orderBy(‘id’, ‘DESC’)->get(); i want to filter data if current date is greater than expiry date then those record should not be shown but in my scenario i’m still getting record. Any solution Thanks. Sourc..

Read more

I’m generating pdf using dom pdf. Code : $dompdf = new Dompdf(); $pdfData=Data::where(‘id’,auth()->user()->id)->first(); $html = view(‘admin/view-data/’,[‘pdfData’=>$pdfData])->render(); $dompdf->loadHtml($html); $dompdf->setPaper(‘A4’, ‘portrait’); $dompdf->render(); $fileName = ‘filenaname.pdf’; Storage::put(‘public/pdf’.$fileName, $dompdf->output()); pdf is being generated in the storage/app/public/pdf/ folder i’m downloading it using vue.js : Link: <a href="#" class="btn btn-xs btn-success" title="Downaload" @click="downloadIt(‘/storage/’+user.user_id)"><i class="fa fa-file-pdf" aria-hidden="true"></i></a> Method: downloadIt(url) { var str ..

Read more

I have product table Product table: id | title | price | user_id Menu Planner Table: id | day | category_id | product_id | user_id Product Model: class Product extends Model { public function menuplanner() { return $this->belongsTo(MenuPlanner::class); } public function check($Catid,$productID,$userID,$day) { return $this->menuplanner()->select(‘product_id’)->where(‘product_id’, ‘=’, $productID)->where(‘user_id’, ‘=’, $userID)->where(‘day’, ‘=’, $day)->first(); } } MenuPlanner Model: ..

Read more

I have created my application using laravel and vue.js and hosted my application on server in subfolder inside public_html, Accessing it using url like this: https://maindomain.in/projectfolder/public/login but after login if i click on any link it points back to https://maindomain.in/dashboard and i get 404 not found in console for the api routes that are accessed ..

Read more

//Blade Page @foreach ($permission as $permissions) <tr> <td class="text-center">{{$permissions->id}}</td> <td>{{$permissions->name}}</td> @foreach ($role as $roles) <td class="text-center"> @if ($roles->name == ‘admin’|| $roles->name == ‘superadmin’) <span class="feather feather-check text-success icon-style-circle bg-success-transparent"></span> @else @csrf <input type="hidden" name="name" class="role" value="{{$roles->name}}"> <input type="hidden" name="role_id" class="role_id" value="{{$roles->id}}"> <input type="hidden" class="permissionid" name="permission[]" value="{{$permissions->id}}"> @foreach ($permissionrule as $item) @if ($loop->index) @if ($item == ..

Read more

I’m using Laravel Notification and i want to save data in my database table if i write my insert query then i’m getting following error otherwise Notification are running : TypeError: Return value of AppUser::getLogNameToUse() must be of the type string, null This is the query public function toMail($notifiable) { $users = User::find($notifiable->id); $users->verification_link=$link; $users->save(); ..

Read more

//this is my blade <form method="POST" action="{{url(‘/admin/article/’.$article->id.’/edit’)}}" enctype="multipart/form-data"> @csrf <div class="card-body"> <div class="form-group"> <label class="form-label">Title</label> <input type="text" class="form-control @error(‘title’) is-invalid @enderror" name="title" value="{{$article->title}}"> @error(‘title’) <span class="invalid-feedback" role="alert"> <strong>{{ $message }}</strong> </span> @enderror </div> <div class="form-group"> <label class="form-label">Category</label> <select class="form-control custom-select select2 @error(‘category’) is-invalid @enderror" data-placeholder="Select Category" name="category" > <option label="Select Category"></option> @foreach ($category as $category) ..

Read more

// LIke the page code public function like($id){ $user_id = Auth::user()->id; $like_user = article_likes::where( [‘user_id’=>$user_id, ‘article_id’ => $id] )->first(); if(empty($like_user->user_id)){ $user_id = Auth::user()->id; $article_id = $id; $likes = new article_likes(); $likes->user_id = $user_id; $likes->article_id = $article_id; $likes->save(); return redirect()->back(); }else{ return redirect()->back(); } } // Dislike the page public function dislike($id){ $user_id = Auth::user()->id; $like_user ..

Read more

// LIke the page code public function like($id){ $user_id = Auth::user()->id; $like_user = article_likes::where( [‘user_id’=>$user_id, ‘article_id’ => $id] )->first(); if(empty($like_user->user_id)){ $user_id = Auth::user()->id; $article_id = $id; $likes = new article_likes(); $likes->user_id = $user_id; $likes->article_id = $article_id; $likes->save(); return redirect()->back(); }else{ return redirect()->back(); } } // Dislike the page public function dislike($id){ $user_id = Auth::user()->id; $like_user ..

Read more