dimanche 31 mai 2020

laravel validation error and flash session not working

I have installed laravel 5.8 project via :

composer create-project --prefer-dist laravel/laravel project2"5.8.*"

after I run:

php artisan make:auth

I can visit 127.0.0.1:8000/login but when I enter wrong email or password I get redirected back without error messages.

here is my rutes:

 Domain | Method   | URI                    | Name                 | Action                                                                 | Middleware   |
+--------+----------+------------------------+----------------------+------------------------------------------------------------------------+--------------+
|        | GET|HEAD | /                      |                      | Closure                                                                | web          |
|        | GET|HEAD | api/user               |                      | Closure                                                                | api,auth:api |
|        | POST     | complete-registration  | completeRegistration | App\Http\Controllers\auth\RegisterController@completeRegistration      | web,guest    |
|        | GET|HEAD | home                   | home                 | App\Http\Controllers\HomeController@index                              | web          |
|        | GET|HEAD | login                  | login                | App\Http\Controllers\Auth\LoginController@showLoginForm                | web          |
|        | POST     | login                  |                      | App\Http\Controllers\Auth\LoginController@login                        | web          |
|        | POST     | logout                 | logout               | App\Http\Controllers\Auth\LoginController@logout                       | web          |
|        | POST     | password/email         | password.email       | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web,guest    |
|        | GET|HEAD | password/reset         | password.request     | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest    |
|        | POST     | password/reset         | password.update      | App\Http\Controllers\Auth\ResetPasswordController@reset                | web,guest    |
|        | GET|HEAD | password/reset/{token} | password.reset       | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web,guest    |
|        | GET|HEAD | register               | register             | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web,guest    |
|        | POST     | register               |                      | App\Http\Controllers\Auth\RegisterController@register                  | web,guest    |
|        | GET|HEAD | verify-code            | verify_code          | App\Http\Controllers\auth\RegisterController@show_verify_code          | web,guest    |

I tried:

php artisan clear:cache
php artisan config:cache
php artisan view:clear
php artisan route:clear

also tried to delete vendor folder and then:

composer install install --no-cache

but nothing worked, why laravel is not returning errors?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ciY52z
via IFTTT

Laravel and VueJs: Cannot set property 'cats' of undefined

I'm having this code in the blade:

<list-categories-component></list-categories-component>

and this template with vue code

<template>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Example Component</div>
                <div class="card-body">
                    <ul>
                    <li v-for="cat in cats" :key="cat.cat_id"></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
</template>

<script>
export default {
    data(){
        return{
            cats:[],
        };
    },
    created() {
        this.fetchTaskList();
    },
    methods:{
        fetchTaskList(){
            axios.get('/api/listCats')
                .then(function (response) {
                    console.log(response.data.cats);
                    this.cats = response.data.cats;

                })
                .catch(function (error) {
                    // handle error
                    console.log(error);
                });
        }

    }
}
</script>

and here's the axios response

Axios response

and here's the log

console logs

but data can't be rendered successfully as it find an error here

this.cats = response.data.cats;

I changed this.cats = response.data.cats to this.cats = response.data to catch the array itself but still getting the same error.

I'm running npm run watch so what's the problem here and how to fix it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Xlbvao
via IFTTT

I'm having problems installing composer. The error being displayed is

[InvalidArgumentException] Could not find package laravel/laravel with version dev-develop in a version installable using your PHP version 7.2 .1.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zP0UeB
via IFTTT

Created at timestamp is null when retrieve

I am saving data using sensor where data is coming like this

$input = $request["date"].' '.$request["time"]; 

        $newDate= DateTime::createFromFormat('d/m/Y H:i:s',$input);     
$created_date = $newDate->format('Y-m-d H:i:s'); // for example
    try{

           $SensorData = SensorData::create([
            'sensor_id' => $request['sensor']['id'],            
            'created_at' => "".$created_date."",


        ]);

$sensor_data=SensorData::join('sensors','sensors.id','=','sensor_id')->orderBy('sensor_data.created_at','DESC')->get();

its saving datetime in database as 2020-05-04 01:10:12 but when retrieve value it shows null



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2MeuRaP
via IFTTT

Laravel taking time to loop through 100000 records in blade?

I am trying to loop through 100000 records in select tag but it is taking about one minute to load whole page. I tried to chunk method but it is also taking long time. what should i do?

Controller

public function create()
{
    $addresses = Address::where('status', 1)->get();

    return view('web.pages.transports.consignments.create', compact('addresses'));
}

Blade

<div id="pickup_address" style=" max-width: 100%;">

    <label class="form-control-label">Pickup Address</label>
    <select class="form-control kt-selectpicker " name="pickup_address" id="pickup_address_id" data-live-search="true" required>
        <option value="">Select Address</option>
        @foreach($addresses as $address)

            <option class="wrapword" value="">, , ,, , , </option>
        @endforeach
    </select>
</div>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2yNPw2a
via IFTTT

Laravel and XAMPP

I have a question regarding Laravel. I use XAMPP for a localhost database, and when I put the Laravel files, in the HTDOCS folder (of XAMPP), it shows me the Index of /laravel, instead of the default PHP page. Is there a way I can open the site with XAMPP without using "php artisan serve" in CMD?

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3euqXqa
via IFTTT

sql pv: query in laravel

I want to write the laravel query for working sql below query.below query executed correctly in sql how to the above query in laravel for postgresql db

select  id,
        user_name,
        reported_to 
from    (select * from user_master
         order by reported_to) orrdered,
        (select @pv := 'prathap Achuthan') initialisation
where   find_in_set(reported_to, @pv)
and     length(@pv := concat(@pv, ',', user_name))


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZUhqoy
via IFTTT

samedi 30 mai 2020

recursive query to fetch user list

I have the table user which has user_name and manager name.I want to get the user who are having ramya as manager and reportee's reportee

users table

SNO user_name   manager
1    vani        Ramya
2    ramya       geetha
3    priya       ramya
4    mani        ramya
5    latha       vani
6.   hema        Anitha 
7.   kavitha     latha
8    Mala        kavitha

I want to get the name ramya and ramya's reportee vani,priya and mani and get latha who is having vani as manager who is having ramya as manager. I want to get ramya,vani,priya,mani,latha,kavitha,mala and so it if mala have any reportee. I'm trying this for laravel query

http://sqlfiddle.com/#!9/39a98e/1

select a.user_name from 
users a left join users b
on a.manager=b.user_name
where a.user_name='Ramya' or a.manager='ramya' or b.manager='Ramya'

now caught only ramya,vani,priya,mani,latha



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36JFE60
via IFTTT

Recursive query in laravel

I have a table user with a fields id,user_name,manager,geo .I want to get the user (a) and his repotee(b) and b' reportees and so on for the geo US .From the table I want to get the result as IF a login[a,c,d] if e login [e]

user_name   manager   geo
a            x        US
b            a        UK
c            a        US
d            b        US

e            Y        UE
f            e        US

I have tried as

$filter_username_details=DB::table('user_master as a')->leftjoin('user_master as b', 'a.reports_to', '=', 'b.user_name')->where('a.user_name',$user_name)->orwhere('a.reports_to',$user_name)->orwhere('b.reports_to',$user_name)->whereIn('a.geo',$geo)->groupBy('a.user_name')->pluck(
            'a.user_name')->toArray();

getting wrong output as loading all the value has 'US'



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZSH90g
via IFTTT

Laravel Command Unexpected Failure

I have few commands which happens to fire at the same time 6:30am. I noticed that one of my command wasn't executed, no failed job entries, no logs wasn't even initiated.

I researched and couldn't find anything solid. I did fix this by changing time of my other crons to 6:33am 6:37am instead of all being executed at 6:30am which started working perfectly.

I am assuming that if there is any issue in one command job and it fails, another command isn't executed and since laravel artisan commands runs every minute so other commands which didn't have any other commands at same time were executed properly.

Is there anything i can do to fire multiple commands without interruptions even though first commands fails, all which are supposed to be executed at same time?? How can we handle this.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2AmbJEX
via IFTTT

Access only visible class selector which is showing in the slider. Currently getting all the class element

In the slider, I am showing invoices. Through JS automatic calculation is done like total price calculation. In the view invoice blade file it is working fine but in the send all invoices preview page the calculation is not working properly. It is getting all the class selector. Is there any way only visible class e will be accessed instead of getting all the price class selector?

here is the JS for total price calculation

function update_total()
   {
      var sum = 0;
      $('.price').each(function(){
         var price = $(this).val();
         if(price != ''){
           sum = parseFloat(sum)+parseFloat(price);
         }
      });
      $('.late_price').each(function(){
         var x = $(this).val();
         if(x != ''){
           sum = parseFloat(sum)+parseFloat(x);
         }
      });
      $('.lost_price').each(function(){
         var y = $(this).val();
         if(y != ''){
           sum = parseFloat(sum)+parseFloat(y);
         }
      });
      $('#subtotal_price').val(sum);
   }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3clWRUm
via IFTTT

Unisharp FileManager AWS S3 Image Resize Issue - Image source not readable

unisharp/laravel-filemanager: 2.1, Laravel 7.6

When I was going to resize image, it returns

Intervention\Image\Exception\NotReadableException
Image source not readable

I went through some vendor library and debugged. As the result, pathPrefix returned null.

enter image description here

Here is my config for AWS S3.

's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET_PUBLIC'),
            'endpoint' => env('AWS_ENDPOINT'),
            'visibility' => 'public'
        ],

Am I missed something?

Can anyone help me?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3eLkwPV
via IFTTT

select query in laravel

I have created a my application in laravel.my sql query is working fine.I'm bit struck with laravel query

select a.type from chart_table a left join color_codes b on a.type=b.type_id group by a.type

For the above query tried as

DB::table('chart_table')
    ->leftjoin('color_codes','color_codes.type_id','=','chart_table.type')
    ->whereIn('chart_table.user_name',$filter_username_details)
    ->orderBy('color_codes.id', 'asc')
    ->groupBy('chart_table.type')
    ->pluck('chart_table.type')
    ->toArray();

I'm getting the error as

SQLSTATE[42803]: Grouping error: 7 ERROR:  column &quot;color_codes.id&quot; must appear in the GROUP BY clause or be used in an aggregate function<br />
LINE 1: ...le&quot;.&quot;type&quot; group by &quot;chart_table&quot;.&quot;type&quot; order by &quot;color_cod..

What I did wrong in my query



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zzB4eJ
via IFTTT

laravel 7 edit old value not selected form

hello i use this code for select category in edit form and it is not work! this line not work

<option value=""  >

and use this but two code not worked!

 

my code is

 <option value="0">دسته اصلی</option>
@foreach(\App\Category::all() as $category)
<option value=""  >
 @if($category->parent== 0)
 
 @else
-- 
 @endif
</option>
@endforeach

and my model category this

  public function child()
{
    return $this->hasMany(Category::class, 'parent', 'id');
}

public function get_parent()
{
    return $this->hasOne(Category::class,'id','parent');
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TVbuI1
via IFTTT

imap open gives error for custom email laravel

I am trying to connect custom email through imap but receiving error imap_open(): Couldn't open stream {domain.com:143/imap/ssl}. TLS/SSL failure for domain.com:. Can please let me know what is wrong here.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dneogs
via IFTTT

vendredi 29 mai 2020

Laravel Forge Stripe ENV keys stopped working, still working fine on local dev

I have a Laravel 5.5 app using Stripe for subscriptions, deployed on Forge/Digital Ocean.

Everything has been working fine for many months, but today both environmental variables env('PUB_STRIPE_API_KEY') and env('STRIPE_API_KEY') are showing as not present (if(empty) is coming up true for both variables) and Stripe functionality is therefore stopped. Both are present and accounted for in my .ENV file.

STRIPE_API_KEY=sk_test_fPpKzHV49vImGOh4Aqxxxxxx
PUB_STRIPE_API_KEY=pk_test_HrVhWbsRL90qm7RrCbxxxxxx

However, my identical local development instance works just fine. Both were just fine a few days ago and no changes have been made to any Stripe or .ENV code. I'm perplexed.

Other .ENV variables, such as database connection parameters, all seem fine. Only Stripe is effected.

I have checked the .ENV file. I have cleared cache (php artisan cache:clear). No difference. I don't know where to go from here. Any suggestions...?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3diOdqZ
via IFTTT

Where can i put the paginate()

I am trying put the paginate(10), to add a pagination later, put when i put give me this error:

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$product

Here my controller here i want add the pagination(10):

 public function index()
    {
        $user_id = auth()->user()->id;
        $user = User::find($user_id);

        return view('your')->with('product', $user->product);
    }

I did try this:

 public function index()
    {
        $user_id = auth()->user()->id;
        $user = User::find($user_id)->paginate(10);

        return view('your')->with('product', $user->product);
    }

Thanks for you help!!!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3erL884
via IFTTT

Laravel - Uncaught TypeError: Cannot read property 'style' of undefined

My Error image attached below enter image description here

I want to implement multiple filter in my view file of Laravel project. For above requirement i put a select list in my view file above the table area and after that i put some lines of code in my controller. after that i create a route for this in my web.php file. at last i put a script in my view file.

SeoKeywordController.php

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Brian2694\Toastr\Facades\Toastr;
use Illuminate\Support\Facades\Log;
use App\Seokeyword;
use App\Project;
use App\Link;
use Validator;

use DB;

class SeoKeywordController extends Controller
{
    public function index()
    {
        $seokey = Seokeyword::latest()->get();
        return view('admin.seokeyword.index',compact('seokey'));
    }
    public function getKeyword(Request $request)
    {
        if(request()->ajax())
         {
              if($request->keyword)
              {
               $data = DB::table('seokeywords')
                 ->select('seokeywords.id','seokeywords.keyword')
                 ->where('seokeywords.keyword', $request->keyword);
              }
              else
              {
               $data = DB::table('seokeywords')
                 // ->join('category', 'category.category_id', '=', 'product.category')
                 ->select('seokeywords.id', 'seokeywords.keyword');
              }
          return datatables()->of($data)->make(true);
         }

         $keyword = DB::table('seokeywords')
            ->select("*")
            ->get();
         return view('admin.seokeyword.index', compact('keyword'));

    }
}

index.blade.php {view file}

@section('content')
<div class="container-fluid">
            <!-- ============================================================== -->
            <!-- Start Page Content -->
            <!-- ============================================================== -->
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-body">

                                <div class="button-group">

                                    <div class="row form-body">
                                        <div class="col-sm-6">
                                            <a type="button" class="btn waves-effect waves-light btn-primary" href="">Add New Keyword</a>
                                        </div>
                                        <div class="col-sm-6 form-group">
                                            <form>
                                            <select name="keyword" id="keyword" class="form-control">
                                                @foreach($seokey as $keyword)
                                                <option value=""></option>
                                                @endforeach
                                            </select>
                                            </form>
                                        </div>
                                    </div>

                                </div>

                                <div class="table-responsive">

                                    <table id="test" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Project</th>
                                                <th>Web Url</th>
                                                <th>Seo Keyword</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
                                        <tfoot>
                                            <tr>
                                                <th>ID</th>
                                                <th>Project</th>
                                                <th>Web Url</th>
                                                <th>Seo Keyword</th>
                                                <th>Action</th>
                                            </tr>
                                        </tfoot>
                                        <tbody>
                                            @foreach($seokey as $key=>$ke)
                                            <tr>
                                                <td></td>

                                                <td></td>
                                                <td><a class="btn btn-primary btn-sm" href="" target="_blank" title="">Click Here</a></td>
                                                <td><span title=""></span></td>
                                                <td>
                                                    <a href="" class="btn btn-info btn-m btn-circle">
                                                        <i class="ti-pencil"></i>
                                                    </a>
                                                    <button class="btn btn-danger btn-m btn-circle" type="button" onclick="deletePost()">
                                                        <i class="ti-trash"></i>
                                                    </button>
                                                    <form id="delete-form-" action="" method="POST" style="display: none;">
                                                        
                                                        
                                                    </form>

                                                </td>

                                            </tr>
                                            @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>

@endsection
@push('js')
<script>
$(document).ready(function(){

    fetch_data();

    function fetch_data(keyword = '')
     {
      $('#test').DataTable({
       processing: true,
       serverSide: true,
       ajax: {
        url:"",
        data: {keyword:keyword},
        type: 'GET'
       },
       columns:[
            {
                data: 'id',
                name: 'id'
            },
            {
                data: 'project_id',
                name: 'project_id'
            },
            {
                data: 'link_id',
                name: 'link_id'
            },
            {
                data: 'keyword',
                name: 'keyword'
            },
            {
                data: 'created_at',
                name: 'created_at'
            },
            {
                data: 'updated_at',
                name: 'updated_at'
            }

        ]
      });
    }

     $('#keyword').change(function(){
          var id = $('#keyword').val();

          $('#test').DataTable().destroy();

          fetch_data(id);
     });

});
</script>
@endpush

if anyone have any solution or some suggestion then please comment. and also if you have better option to implement filter in laravel project then suggest me the link. Thanks



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3exivGJ
via IFTTT

hasOne with select and where condition

I have two tables:

  1. ForumPost
+---------+---------+
|      id | message |
+---------+---------+
  1. ForumPostVote
+---------+---------+---------+
|      id | post_id | user_id |
+---------+---------+---------+

Here are my two model classes for each:

  1. ForumPost.php
class ForumPost extends Model
{
    protected $with = [
        'userVote'
    ];

    public function votes()
    {
        return $this->hasMany('App\ForumPostVote', 'post_id', 'id');
    }

    public function userVote()
    {
        if (Auth::check())
        {
            return $this->hasOne('App\ForumPostVote', 'post_id', 'id')->where('user_id', Auth::user()->id)->select('id');
        }

        return null;
    }
}
  1. ForumPostVote.php
class ForumPostVote extends Model
{
    public function user()
    {
        return $this->belongsTo('App\User');
    }

    public function post()
    {
        return $this->belongsTo('App\ForumPost', 'id', 'post_id');
    }
}

As you can see, in ForumPost.php, I have a function userVote() where I try to to select the id from ForumPostVote where the user ID matches the logged in user.

However, it seems to be returning null, even though there is a record in the database. If I remove ->select('id') from the query, it returns fine, but it returns the whole object, when all I want is just the id.

What am I doing wrong?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Xcvwjd
via IFTTT

Call to undefined method App\Product::link()

Help me, i am trying put some pagination in my page, but keep showing this error Call to undefined method App\Product::link()

my Code

Blade:

@extends('layouts.index')
@section('content')

<!-- TOP Navbar -->
<div class="w-100 shadow d-flex position-relative position-fixed" style="z-index: 2; background-color: white; ">

    <div class="d-flex justify-content-center py-3 mr-auto" style="width: 200px">
        <img src="/images/logo.svg" alt="logo icon">
    </div>

    <div class="pt-4 bd-highlight"><a href="/">
            <a href="/create">
                <button type="button" class="btn font p-auto rounded-pill text-white font-weight-bold "
                        style="background-color: #28AD47; width: 178px; height: 40px">New Product
                </button>
            </a>
        </a>
    </div>

    <div class=" bd-highlight">
        <div class="dropdown px-5" style="padding-top: 24px">
            <a class=" align-middle font dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
               data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
               style="color: #2c3539">                    

            </a>

            <div class="dropdown-menu mt-4" aria-labelledby="dropdownMenuLink" x-placement="bottom-start"
                 style="position: absolute; transform: translate3d(-20px, 38px, 0px); top: 0px; left: 0px; will-change: transform;">
                <a class="dropdown-item" href=""><i class="fa fa-btn fa-user"></i>Profile</a>
                <a class="dropdown-item" href=""
                   onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                    Logout
                </a>

                <form id="logout-form" action="" method="POST" style="display: none;">
                    
                </form>
            </div>
        </div>
    </div>
</div>

<!-------------------------->

<div style="background-color: #F8F8F8; z-index: 0;" class="d-flex justify-content-start ">
    <div style="width: 200px; height: calc(100vh - 70px);margin-top: 73px;z-index: 1"
         class="bg-white shadow position-fixed ">
        <div class="d-flex justify-content-center">
            <a href="/create">
                <p class="font my-5" style="color: #525252"><img src="/images/plus.svg" class="mr-3" alt="plus icon"
                                                                 width="16px" height="16px">
                    New Product
                </p>
            </a>
        </div>

        <div class="d-flex justify-content-center">
            <p class="font my-5" style="color: #525252"><img src="/images/edit.svg" class="mr-3" alt="edit icon"
                                                             width="16px" height="16px">
                Edit Product
            </p>

        </div>
    </div>

    <div class="w-100 " style="margin-top: 73px;margin-left: 200px">
        <div class="d-flex justify-content-center">
            <h1 class="font p-5">All products</h1>
        </div>
        <!-- <div style="height: calc(100vh -  202px);background-color: #676767">-->
        <div class=" d-flex justify-content-center flex-wrap">
            @foreach($products as $product)
                <div class="product shadow m-4">
                    <div class="d-flex justify-content-center mt-3">
                        <img src="/images/car-example.png" alt="car photo" width="190px" height="140px">
                    </div>

                    <div>
                        <p class="font text-white pt-4 pl-5" style="font-size: 16px">
                             <img src="/images/info.svg" alt="info icon" width="20px"
                                                     height="15px" class="pl-2 mb-1 red-tooltip"
                                                     data-toggle="tooltip"
                                                     data-placement="right" title=" ">
                        </p>
                    </div>

                    <div class="d-flex  bd-highlight" style="margin-top: 40px">
                        <div class="pl-5 mt-auto bd-highlight">
                            <h3 class="font text-white">$</h3>
                        </div>

                        <div class="bd-highlight ml-auto mt-3 pr-5">

                            <a href="/">
                                <button type="button"
                                        class="btn font rounded-pill text-white font-weight-light "
                                        style="font-size: 18px;background-color: #28AD47; width: 99px; height: 41px">
                                    Buy
                                </button>
                            </a>
                        </div>
                    </div>
                </div>

            @endforeach

        </div>

        <div class="w-100" style="background-color: white; z-index: 0;">
            <div class=" d-flex justify-content-center pt-2">
                    
            </div>
        </div>

    </div>
</div>





<!-- Bootstrap Link -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip()

        })
    </script>

    <!-- Hover -->


 @endsection

Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Product;

class ProductController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index()

{
    $products = Product::orderBy('name')->paginate(10);
    return view('show')->with('products', $products);
}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    return view('create');
}

/**
 * Store a newly created resource in storage.
 *
 * @param \Illuminate\Http\Request $request
 * @return \Illuminate\Http\Response
 */



public function store(Request $request)
{

    $this->validate($request, [
        'name' =>'required | unique:product|max:64',
        'description' => 'required',
        'price' => 'required',
    ]);


    print_r($request->input());
    $product = new Product;
    $product->name = $request->name;
    $product->description = $request->description;
    $product->price = $request->price;
    echo $product->save();

    return redirect('/home');
}

/**
 * Display the specified resource.
 *
 * @param int $id
 * @return \Illuminate\Http\Response
 */
public function show($id)
{

}

/**
 * Show the form for editing the specified resource.
 *
 * @param int $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    //
}

/**
 * Update the specified resource in storage.
 *
 * @param \Illuminate\Http\Request $request
 * @param int $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param int $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    //
}

}

web.php:

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::resource('home', 'ProductController');

Route::get('profile', 'UserController@profile')->middleware('auth');

Route::post('profile', 'UserController@update_avatar')->name('profile');

Route::view('create', 'create')->middleware('auth');

Route::post('submit', 'ProductController@store');


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZRuDya
via IFTTT

Laravel Dynamic Rate Limiting - Exponential Throttling

I am approaching the laraverl built-in throttling middleware to protect some of my REST APIs from possible scrapers or other not authorized operations. I have obviously implemented other methods apart from throttling to prevent that, but I think this piece is essential to make the system more safe overall.

I have generally understood how the throttle system works and I could implement it easly. My question is: is it possible to make the throttle exponential?

Let me explain better:

  • A user is initally blocked for 1 minute
  • If The user reaches the limit again in the 1 minute after, he is then blocked for 2 minutes
  • If all this happens again, the user is blocked for 4 minutes
  • If the user behave well in the next 4 minutes, the block gets reduced to 2 and so on

If you think my implementation is wrong and it could be done better in another way, I am happy to hear that. Otherwise the question is how to implement this on Laravel.

Thank you!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BhdrrT
via IFTTT

Setting debug:false causes my server to display Error 500 Laravel

I have set the debug in my production server to false in my .env file and it shows this error. This happens in my production server but not in my local. Here's my .env file

APP_NAME=project
APP_ENV=local
APP_KEY=base64:K6KGUnG8qiBO8/d+v3gyVIZvg1QImKoZE4nPPTwi4f4=
APP_DEBUG=false
APP_URL=my_url

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=myhist
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=uname
DB_PASSWORD=password

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36GlTw9
via IFTTT

jeudi 28 mai 2020

localhost is currently unable to handle this request.HTTP ERROR 500

] PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 16384 bytes) in C:\xampp\htdocs\laravel\storage\framework\views\9ce6cdaa24325154033f80a71530d196495aafb3.php on line 2



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ddxzcn
via IFTTT

After updating composer i am getting Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()

I ran composer update and also i updated php version, Now i am getting below error msg on my every laravel project

Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()

I am using xampp.

what i tried

i reinstall my composer by running composer install but i got

[Composer\Exception\NoSslException]

i updated path environment variable to php.ini,But still getting this error what should i need to do ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2XLTO2K
via IFTTT

Iframe login resulting in Page Expired

So i have created two website one is for front page (WordPress) and the other one is for Member Area (Laravel) because of various reason .. i have to make the login button in front page to become popup iframe

iframe popup

So when i click login it will redirect me to member area (i'm using targer="_parent"). But when i tried to login it will return with this

page expired

Does anyone have idea how do i fix this?

PS : the website url is like this WordPress (testing.com), Laravel (members.testing.com)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TMNwhU
via IFTTT

How to set custom js file in Laravel admin template

I am using Laravel 5.8 with laravel-admin Template for admin. Now in some situation i need custom js and css file only for admin specific controller. How to add these Js and css in laravel-admin.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2AkVkR2
via IFTTT

Laravel dynamic config variable get

This is my config/filesystems.php file.

'default' => env('FILESYSTEM_DRIVER', 's3'),

'disks' => [
       's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
        ],
       'b2' => [
            'driver' => 's3',
            'key' => env('B2_KEY_ID'),
            'secret' => env('B2_APP_KEY'),
        ],
]

How can I get default filesystem's key value? I think this is possible.

config("filesystems.disks." . config("filesystems.default") . ".key");

I believe there is any better way. Can anyone help me?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZMm8Vh
via IFTTT

Laravel get storage url with custom subfolders inside storage directory where files are stored

In my Laravel(v5.8.x) project, I have implemented the function of uploading images thro' CKEditor(v4.14.x).

But I want to store and fetch images from storage/wysiwyg/[AnyDir] path.

I have this code with Storage facades included:

public function upload(Request $request)
{
    $destPath = storage_path() . DS . 'wysiwyg' . DS . '[AnyDir]';
    if ($request->hasFile('upload')) {
        $originName = $request->file('upload')->getClientOriginalName();
        $fileName = pathinfo($originName, PATHINFO_FILENAME);
        $extension = $request->file('upload')->getClientOriginalExtension();
        $fileName = $fileName.'_'.time().'.'.$extension;

        $request->file('upload')->move($destPath, $fileName);

        $CKEditorFuncNum = $request->input('CKEditorFuncNum');
        $url = Storage::url($fileName);
        exit($url);
        $msg = 'Image uploaded successfully';
        $response = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$msg')</script>";

        @header('Content-type: text/html; charset=utf-8');
        echo $response;
    }
}

But the Storage::url method ignores the subfolders wysiwyg and [AnyDir], how do I get full storage url along with subfolders in proper order ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3euAjm0
via IFTTT

php laravel 7 rest api upload file with passport token

what i try is to submit from from front end (anguler) a form with a file with user token in request header to my backend php laravel7 rest api

and when i try i have this error

 local.ERROR: Invalid stream reference provided {"exception":"[object] (Laminas\\Diactoros\\Exception\\InvalidArgumentException(code: 0): Invalid stream reference provided at C:\\inetpub\\jalssa\\jalssaBE\\vendor\\laminas\\laminas-diactoros\\src\\Stream.php:345)
[stacktrace]
#0 C:\\inetpub\\jalssa\\jalssaBE\\vendor\\laminas\\laminas-diactoros\\src\\Stream.php(60)

my route code

Route::middleware('auth:api')->post('/postVerificationRequest', function (Request $request) 
{
    \Log::info('start 111111  '.$user);

    $user= $request->user();


    \Log::info('start 22222222  '.$user);

    if($user!= null && $user->id> 0)
    {
        return app('App\Http\Controllers\API\VerificationController')->postVerificationRequest($user->id);
    }

    return $user;
});

i tried alot of other methods like

class VerificationController extends Controller
{
    public function __construct()
    {
        $this->middleware('client.credentials')->only(['postVerificationRequest']);
    }
...

what i need is just any direct way that i can validate passport token within my controller function easy direct way i will send the token as a parameter or within request header

lareval 7 passport token



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2X9Vgwr
via IFTTT

Laravel trait except for specific function

I am using Trait for one model in Laravel 7.

namespace App;

use App\Traits\AutoFieldTrait;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class BlogPost extends Model implements HasMedia
{
   use AutoFieldTrait;
   use InteractsWithMedia;

   public function fun1() { ... }

   public function fun2() { ... }

   public function registerMediaConversions(Media $media = null): void
   {
     $this->addMediaConversion('thumb')
        ->width(368)
        ->height(232)
        ->sharpen(10);
   }

}

AutoFieldTrait is to add one additional where clause automatically.

I want it for fun1() and fun2(), but I don't want to it will be applied to registerMediaConversions() .

Is there any way to exclude some functions from trait?


Here is AutoFieldTrait.

<?php

namespace App\Traits;

trait AutoFieldTrait{
    public static function bootAutoFieldTrait()
    {
        static::addGlobalScope(new AutoFieldScope());
    }
}

namespace App\Traits;

use Illuminate\Database\Query\Builder as BaseBuilder;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Scope;
use Illuminate\Database\Eloquent\Model;

class AutoFieldScope implements Scope {
    public function apply(Builder $builder, Model $model)
    {
        $builder->where('user_id', '=', auth()->user()->id);
    }
}

And registerMediaConversions() is from laravel-medialibrary package.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TKHjTS
via IFTTT

Laravel Amazon s3 for prod but not dev

I am trying to set up a dev environment for a Laravel app we have had written and the person who wrote it is not being overly helpful. They use an Amazon S3 bucket to store the files but we want to have everything on our development server. The PHP files seem to have 'https://domain.s3.eu-west-2.amazonaws.com/media/' hardcoded all over the place. Any pointers as to how to unravel this and store files locally would be good. Ideally having production on s3 and development and test environments using local filesystem (or maybe some type of service using the same protocol). If not this then how do we modify the code so this stuff is not hardcoded. we want to use the same code base for all environments in git.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2McVtbT
via IFTTT

php if condition not working in laravel controller

Help post php if condition not working in laravel controller

<div class="price-box float-left">
                                <?php if('.$home_base_price.' != '.$home_discounted_base_price.'): ?>
                                        <del class="old-product-price strong-400">
                                                '.$home_base_price.'
                                        </del>
                                <?php endif ?>
                                        <span class="product-price strong-600"> 
                                         '.$home_discounted_base_price.'
                                        </span>
                                    </div>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3gGkFG2
via IFTTT

Laravel custom auth based on json data

I am trying to make auth based on third party api in laravel. not storing or using data from my local db. Here I am keeping api response data as an array just for visualization . It shows error Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, string given, called in vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php . How can I fix that. I also made R&D on it. Thanks in advance

    $user = [
        'status' => '200',
        'token' => 'aWsIpvOEZfv4sfSRUGS2dDeGw7',
        'id' => '12454545412',
        'user' => [
            'name' => 'xyz',
            'email' => 'xyz@gmail.com',
            'phone' => '12344787',
        ],
    ];

    $user = json_encode($user);
    Auth::login($user);
    return redirect( '/home' );


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c3Pgty
via IFTTT

How to connect DocumentDB and Laravel

I want to connect Laravel with DocumentDB from AWS. But i cant find any document or tutorial about this. is there a way to connect DocumentDB at least to Laravel server?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3eoVHZG
via IFTTT

mercredi 27 mai 2020

How to Access nth Child from Within the Parent Eloquent Model

I have 4 tables with their corresponding models as follows:

//Table is applications
class Application extends BaseModel {
    public function bill(){
        return $this->belongsTo(Bill::class,'bill_id');
    }
}
//Table is bills
class Bill extends BaseModel {
    public function groups(){
        return $this->hasMany(Group::class,'group_id');
    }
}
//Table is groups
class Group extends BaseModel {
    public function items(){
        return $this->hasMany(Item::class,'item_id');
    }
}
//Table is items
class Item extends BaseModel {
    // some props
}

Every Application has Bill which is then divided into Groups. Each group has Items. Note that Items table is the one that defines item and the amount/unitprice of each item.

This is what I want:

From within the Application Model I want to define a function to return Items. I have tried the followings:

class Application extends BaseModel {

    ...

    public function billItems()
    {
        return $this->with('bill.groups.items');
    }

}

All I end up getting is:

"message": "\Application::billItems must return a relationship instance.",
"exception": "LogicException",

What's wrong. What can I do to get it working? I'm using Laravel 5.7



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2XAtKrc
via IFTTT

Remove duplicates in Laravel collection only if previous item is identical

I have a collection of items:

[
    [
    'id' => 1,
    'path' => '/',
    'created_at' => '2020-05-20 20:12:00'
    ],
    [
    'id' => 2,
    'path' => '/somewhere',
    'created_at' => '2020-05-20 21:01:00'
    ],
    [
    'id' => 3,
    'path' => '/somewhere',
    'created_at' => '2020-05-20 21:21:00'
    ],
    [
    'id' => 4,
    'path' => '/somewhere/else',
    'created_at' => '2020-05-20 21:09:00'
    ],
    [
    'id' => 5,
    'path' => '/somewhere/else',
    'created_at' => '2020-05-20 21:10:00'
    ],
]

I need to remove any duplicates where the current item has the same path and is less than 5 minutes old compared to the previous item.

So in this case, item #4 would be removed leaving only #5, but items #2 and #3 would be kept even tho their paths are the same.

How would I do this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dao25T
via IFTTT

Laravel/Vue: Wrapping layout in Vue entry point but can't use in 'content' section

I have Laravel app that I wrapped in a Vue entry point, <div id="app-shop"></div>. I have Vue components I can use in the layout blade with no problem. In the layout blade, I have @yield('content') to display other content. One such section is the shopping cart, such as /cart route which yields my cart.blade file. When I try to use the same component in the cart.blade though, it doesn't show.

Cart.blade.php

@section('content')
    <div>
        <checkout-component></checkout-component>
    </div>
@endsection

Attempting to use it like this does not work. I see no errors in the console but the component doesn't render.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2B9uHiC
via IFTTT

Get the word from sentence that match to an array PHP

Currently I have this variable in php

   @if(count($label_types) > 0)
   @foreach ($label_types as $label_type)
      @if($label_type)
        
      @endif
   @endforeach
   @endif

Which contains the following rows

Waterproof (This is waterproof)

Glossy

Normal

Now since waterproof has the (This is waterproof) on the records

Now I want to only return the words that matches with these keywords

waterproof, glossy, normal

whether they are uppercases, lowercases

For example if the case is : waterproofss with double s

the return would be waterproof



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2M4y10D
via IFTTT

How laravel route:group wrapper works?

Laravel has really nice features of routing which made our life so comfortable. I am so curious about this Route::group() wrapper. How does it work and how does Roue class inside group wrapper get the information at group parameters. Is it maintain any global variable?

Route::group([
    'prefix' => 'audiobook',
    'middleware' => 'auth:api',
    'namespace' => 'Api\Audiobook'
], function () {
    Route::get('latest', 'AudioController@LatestAudioBook');
});


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c2D9Nm
via IFTTT

Laravel Pass value from foreach loop in controller to view

Hi guys can someone help please, i am trying to get the data from a foreach loop in my controller to pass to my view. How do I do it?

This is the controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Student;
use App\Result;
use App\Class_room;

class FormteachersController extends Controller
{
//

    public function form_teachers_view(){
        $UniqueStudent = Student::where('Student_ClassID','JSS 1C')->get();
        foreach ($UniqueStudent as $keydata) {
            $student = $keydata->Stud_id;
            $result= Result::where('Term_ID','1st Term')->where('Student_ID',$student)->where('Class_ID','JSS 1C')->where('Session_ID','2225/2222')->get();
            foreach ($result as $keyresult) {
                echo '<br>'.'<br>'.$student.'-'.$result;
            }
            return view('teachers.form_teachers_comment_sec');
        }
    }
}

This is the output currently by enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TKxrcN
via IFTTT

Laravel debug the Model connection to check if the env function is parsing the credentials properly

Working on multi-database, multi-connection project in Laravel 5.8.x version.

I created a Model for fetching data from specific database using specific connection.

I have defined the connection variable in Model file as:

protected $connection = '[ConnName]';

And I have the said connection set in config/database.php as:

'connections' => [
    '[ConnName]' => [
        'username' => env('username'),
        ....
    ],
    ....
]

Still when I try to load the Model's data into Controller's Index action as:

$modelData = Model::orderBy('created_at', 'DESC');
exit(print_r(compact($modelData)));
return view('entity.index', compact('modelData'));

It prints null/no records, even though there is data in the database linked with model thro' said connection.

Can anyone suggest anyway to cross-check, if the connection credentials are properly parsed thro' env method or just how to print the utilized connection in controller ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36B9rOb
via IFTTT

Laravel php artisan commands hits memory error on every local project after runs a do while loop

I was testing one of my do while loop function and hits an error.
So i terminated php artisan serve command and reload my php and apache on my mac. But after that when i try to php artisan serve and other php artisan xxx commands on my project, it hits the problem below.

xxx-MacBook-Pro:xxxx xxxx$ php artisan serve
PHP Fatal error:  Allowed memory size of 2097152 bytes exhausted (tried to allocate 36864 bytes)

I have tried to set my php.ini memory_limit to 1GB or -1, and restart php and apache but the problem still occurs. This problem also occurs when i try to run serve command on my other laravel projects and running composer install.

Has anyone met the same problem before and how do you solve it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2B8IupD
via IFTTT

How to change delimeter in csv file in Laravel

I am trying to configure the import of a large csv file into the database But I have a problem with delimiter in csv file The standard replacement methods for some reason do not work for me, maybe someone knows other solutions to this problem I will be very grateful for help.

This is my code in ImportController

 $file = file($request->file->getRealPath());
        $data = array_slice($file, 1);
        $parts = str_replace(';', ',', (array_chunk($data, 5000)));
        foreach ($parts as $index => $part)
        {
            $fileName = resource_path('upload/csv/balance/' . date('y-m-d-H-i-s') . $index . '.csv');

            file_put_contents($fileName, $part);
        }
        (new ImportBalance())->importToDb();
        return redirect()->route('admin.balance');



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TL4htY
via IFTTT

Laravel Spatie Roles & Permissions: How to change default tables?

I am using Laravel Spatie Roles & Permissions and wish to change the default roles and permissions tables which power it.

I am changing the table_names values in: <laravel_project>\vendor\spatie\laravel-permission\config\permission.php

The new tables have identical columns and datatypes to the existing columns.

I then run php artisan permission:cache-reset and try to make a change to an existing role or permission but the old table is still being updated and not the new ones as specified in this config file.

What am I doing wrong?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZO4ArT
via IFTTT

Laravel 5.8 VerifyCsrfToken Exception not working

I'm trying to exclude all requests on an endpoint which I call mydomain.com/code so I do like this in the VerifyCsrfToken.php file.

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{
    /**
     * Indicates whether the XSRF-TOKEN cookie should be set on the response.
     *
     * @var bool
     */
    protected $addHttpCookie = true;

    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'code',
        'code/*'
    ];
}

But it does not solve the issue, even after I try to run "php artisan route:clear && php artisan config:clear", Anyone knows why I can't exclude specific routes? (Laravel 5.8)

My route is something like this:

Route::get('code/testing', 'CodeController@testing');

And the only way I figure out is remove the line "\App\Http\Middleware\VerifyCsrfToken::class," from app/Http/Kernel.php to disable Csrf feature which is not a good solution.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TIsSQ8
via IFTTT

Stripe API Balance Deduction

I am trying to implement call features in my project.After successful call i need to deduct the amount according to number of minutes spoken.Lets say the user has an appointment for 50 min and total amount is 500 usd. but the main problem is how can i verify if the caller has enough amount that i.e equal to 500 or more before starting the call so amount will be received according to the minutes.I have been searching answer but couldnt find it.I have used STRIPE for that purpose



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36zjHGN
via IFTTT

how to get excel cell value not formula using laravel controller

Hi guys I am trying to read excel sheet data using laravel controller .

Some cell which contains the excel formula and larvel code is getting the formula not excel cell value.

Can u suggest me the function to get excel cell value not formula.

I am using the following code.

   <?php
    use Illuminate\Database\Capsule\Manager as DB;
    namespace App\Http\Controllers;
   use Illuminate\Http\Request;
   use Illuminate\Http\Response;
   use Illuminate\Foundation\Bus\DispatchesJobs;
   use Illuminate\Routing\Controller as BaseController;
   use Illuminate\Foundation\Validation\ValidatesRequests;
   use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
   use Excel;
   use File;
   use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;

   class techyadeshController extends Controller 
      {
     public function excelUpload(Request $request){

             $data = Excel::toCollection("",$request->file('myFile')); //myFile name of file

                foreach ( $data as $d) {
                $i=1; // to start read excel data from 1st row not from o row
                for($i=1; $i<count($d); $i++)
                {
                 echo $d[$i][0]; // to read first column 
                 echo $d[$i][1]; // second column has excel formula here i want to read cell value

                }
            break; // to read only first excel sheet
            }

        }
     }
       ?>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zxJses
via IFTTT

unable to receive emails on gmail, hotmail but receiving on my own smtp server laravel

I have my own smtp host , i can receive email on my outlook but unable to receive on gmail and hotmail servers.

   try {
            \Config::set('mail.username', env('MAIL_USERNAME_GLU'));
            \Config::set('mail.password', env('MAIL_PASSWORD_GLU'));
            \Config::set('mail.host', env('MAIL_HOST_GLU'));
            \Config::set('mail.port', env('MAIL_PORT_GLU'));
            \Config::set('mail.ssl', env('MAIL_PORT_GLU'));
            // \Config::set('mail.encryption', 'tls');
            Mail::to($data['email'])->cc(env('MAIL_CC_GLU'))->send(new GluRmaNotification($data));
            return ["message" => "Email sent successfully"];
        } catch (\Exception $e) {
            return ['message' => $e->getMessage()];
        }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TCJqsL
via IFTTT

Setting configuration values at runtime

I'm using laravel 5.8 and created a command that runs in the background to keep data updated.

web.php

Route::get('/admin/do_stuff', function () {
    Artisan::call('do:stuff');
    return 'Started!';
});

DoStuff.php

while(config('key.value')){
  doStuff();
  sleep(120);
}

Also got my route (mysite.com/admin/do_stuff) that will start this process, but now I want to add a new route (mysite.com/admin/stop_doing_stuff) to be able to stop it. I've seen in the documentation config variables could be set during runtime https://laravel.com/docs/5.8/configuration#accessing-configuration-values but this doesn't seem to be changing the value at all. Is this possible?

Reading the value from the .env file seems to work but that means I need to edit that file manually and that's not an option, also I could store the value in the database but would like to not doing it. Tried clearing the config cache but getting the same result



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c3Qq8s
via IFTTT

Laravel - Converting RAW query into Eloquent query (Update Query)

i have a table called partner_transaction. On this table i have 4 columns: id, partner_id, type, amount

|id|partner_id |type     |amount|
|--|------------|---------|------|
|1 |65          |Credit   |50    |
|2 |65          |Credit   |20    |
|3 |65          |Debit    |30    |
|4 |10          |Credit   |30    |

now i am introduce a new balance column(current balance) on this table like below.

|id|partner_id  |type     |amount|balance|
|--|------------|---------|------|-------|
|1 |65          |Credit   |50    |50     |
|2 |65          |Credit   |20    |70     |
|3 |65          |Debit    |30    |40     |
|4 |10          |Debit    |30    |-30    |

We wants to re-adjust all balance column by type for a specific partner(65). So we write a raw query -

update partner_transactions pt
inner join (
select
    id, (select sum(case type when 'Credit' then amount when 'Debit' then -amount end)
    from partner_transactions pt2
    where pt2.partner_id = pt1.partner_id and pt2.id <= pt1.id
    ) balance
    from partner_transactions pt1
    WHERE pt1.partner_id = 65
) ptx
on ptx.id = pt.id AND pt.partner_id = 65
set pt.balance = ptx.balance
WHERE pt.partner_id = 65

We are using Laravel 5.2. Now we wants to convert in eloquent. So we write 2 function.

01. For calculating balance -

private function calculateBalanceQuery()
    {
        return DB::table('partner_transactions as pt1')
            ->where('pt1.partner_id', 65)
            ->selectRaw("id, (select sum(case type when 'Credit' then amount when 'Debit' then -amount end)
                from partner_transactions pt2
                where pt2.partner_id = pt1.partner_id and pt2.id <= pt1.id) balance"
            );
    }

02. For update partner_transaction_table -

public function updateQuery()
    {
        return PartnerTransaction::join(DB::raw('(' . $this->calculateBalanceQuery()->toSql() . ') ptx'), function ($join) {
                $join->on('ptx.id', '=', 'partner_transactions.id')->on('partner_transactions.partner_id', '=', DB::raw("'65'"));
            })
            ->where('partner_transactions.partner_id', 65)
            ->update(['partner_transactions.balance' => 'ptx.balance']);
    }

But when execute this script, their was an error occurred.

QueryException in Connection.php line 729:
SQLSTATE[HY093]: Invalid parameter number (SQL: update `partner_transactions` inner join (select id, (select sum(case type when 'Credit' then amount when 'Debit' then -amount end)
from partner_transactions pt2
where pt2.partner_id = pt1.partner_id and pt2.id <= pt1.id) balance from `partner_transactions` as `pt1` where `pt1`.`partner_id` = ptx.balance) ptx on `ptx`.`id` = `partner_transactions`.`id` and `partner_transactions`.`partner_id` = '65' set `partner_transactions`.`balance` = 65 where `partner_transactions`.`partner_id` = ?)

So how could we convert it.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2AhczCL
via IFTTT

mardi 26 mai 2020

Why is 'Illuminate\Auth\SessionGuard' does not have a method 'driver' error coming after Laravel update from 5.1 to 5.2?

I updated a very old Laravel project form 5.1 to 5.2. When I'm testing my app this error occurred 'Illuminate\Auth\SessionGuard' does not have a method 'driver'. No idea what's happening here.

I tried to get the backtrace. It looks like its triggered from AuthServiceProvider but that doesn't help much.

I'll post the backtrace, auth config, and the service provider.

Backtrace

array:3 [
    0 => "Illuminate\Auth\SessionGuard"
    1 => "driver"
    2 => array:11 [
      0 => array:2 [
        0 => "/vagrant/app/Providers/AuthServiceProvider.php"
        1 => 32
      ]
      1 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 731
      ]
      2 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 629
      ]
      3 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
        1 => 697
      ]
      4 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 849
      ]
      5 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 804
      ]
      6 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 774
      ]
      7 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Container/Container.php"
        1 => 629
      ]
      8 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
        1 => 697
      ]
      9 => array:2 [
        0 => "/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php"
        1 => 152
      ]
      10 => array:2 [
        0 => "/vagrant/public/index.php"
        1 => 57
      ]
    ]
  ]

config/app.php

<?php

  return [

      /*
      |--------------------------------------------------------------------------
      | Authentication Defaults
      |--------------------------------------------------------------------------
      |
      | This option controls the default authentication "guard" and password
      | reset options for your application. You may change these defaults
      | as required, but they're a perfect start for most applications.
      |
      */

      'defaults' => [
          'guard' => 'web',
          'passwords' => 'users',
      ],

      /*
      |--------------------------------------------------------------------------
      | Authentication Guards
      |--------------------------------------------------------------------------
      |
      | Next, you may define every authentication guard for your application.
      | Of course, a great default configuration has been defined for you
      | here which uses session storage and the Eloquent user provider.
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | Supported: "session", "token"
      |
      */

      'guards' => [
          'web' => [
              'driver' => 'session',
              'provider' => 'users',
          ],

          'api' => [
              'driver' => 'session',
              'provider' => 'users',
          ],
      ],

      /*
      |--------------------------------------------------------------------------
      | User Providers
      |--------------------------------------------------------------------------
      |
      | All authentication drivers have a user provider. This defines how the
      | users are actually retrieved out of your database or other storage
      | mechanisms used by this application to persist your user's data.
      |
      | If you have multiple user tables or models you may configure multiple
      | sources which represent each model / table. These sources may then
      | be assigned to any extra authentication guards you have defined.
      |
      | Supported: "database", "eloquent"
      |
      */

      'providers' => [
          'users' => [
              'driver' => 'eloquent',
              'model' => Models\UserModel::class,
          ],

          // 'users' => [
          //     'driver' => 'database',
          //     'table' => 'users',
          // ],
      ],

      /*
      |--------------------------------------------------------------------------
      | Resetting Passwords
      |--------------------------------------------------------------------------
      |
      | Here you may set the options for resetting passwords including the view
      | that is your password reset e-mail. You may also set the name of the
      | table that maintains all of the reset tokens for your application.
      |
      | You may specify multiple password reset configurations if you have more
      | than one user table or model in the application and you want to have
      | separate password reset settings based on the specific user types.
      |
      | The expire time is the number of minutes that the reset token should be
      | considered valid. This security feature keeps tokens short-lived so
      | they have less time to be guessed. You may change this as needed.
      |
      */

      'password' => [
          'email' => 'emails.auth.reminder',
          'table' => 'password_reminders',
          'expire' => 60,
      ],
  ];

AuthServiceProvider::registerAuthenticator()

protected function registerAuthenticator()
{
    $this->app->singleton('auth', function ($app) {
        // Once the authentication service has actually been requested by the developer
        // we will set a variable in the application indicating such. This helps us
        // know that we need to set any queued cookies in the after event later.
        $app['auth.loaded'] = true;

        return new AuthManager($app);
    });

    $this->app->singleton('auth.driver', function ($app) {
        return $app['auth']->driver();
    });
}

Any idea what's the issue?

Thank you.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ccBjcZ
via IFTTT

Ajax & Laravel update value from 0 -> 1

    public function getDataTables()
    {
            $datataba = DB::table('contacts')->where('called', 0)->select(['contacts.id', 'contacts.email', 'contacts.name', 'contacts.kontaktm', 'contacts.phone', 'contacts.call', 'contactforms.created_at']);
            return Datatables::of($datataba)
                ->addColumn('action', function($datataba){
                    return '<a href="#"> Set as marked</a>';
                })
                ->make(true);
    }

I want that if someone clicks on the button the value instantly changes from 0 (default value) to 1 in "call"

How can I do it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3d3uRpS
via IFTTT

cant get path for mailable inside module laravel

my mail is inside a module and i cant get the path to this module right in the mail controller return $this->view('ContactUs::welcome'); gets me: No hint path defined for [ContactUs]. my welcome mail is inside a module called ContactUs how to reach ths path /modules/contactus/resources/views/emails/welcome



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Xvj1hv
via IFTTT

Spatie/Laravel-medialibrary can't retrieven file from Backblaze Storage: This driver does not support retrieving URLs

I am using spatie/laravel-medialibrary:8.2 package on my laravel 7.6 project.

I am going to store media data on Backblaze Cloud Storage using gliterd/laravel-backblaze-b2 package.

I made file driver called media as following and using it in media-library.php as file driver.

enter image description here

When I uploaded file, it stored on exact directory what I wanted. But when I was going to retrieve it, I got following error.

This driver does not support retrieving URLs

Media-library package doesn't support for B2 storage?

If so, then I think It's possible to make custom url get function easily.

B2 Bucket info, file directory and filename are stored in media library table.

And file location is as following.

https://f000.backblazeb2.com/file/[bucket name]/[file id]/[file name ] 

Can anyone help me with good solution?

Thanks,



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3emRx4q
via IFTTT

Laravel unique validation Ignore Rule for update

I have a name field on my Client model which must be unique. For the store method I have the following rules:

array (
  'token' => 'string|max:250',
  'directory' => 'max:250',
  'name' => 'required|string|max:250|unique:clients',
)  

For the update method, I have amended this ruleset to ignore the current ID to avoid a duplicate being identified: $rules['name'] = $rules['name'] . ',id,' . $id;

This produces the following ruleset (for record ID 105):

array (
  'token' => 'string|max:250',
  'directory' => 'max:250',
  'name' => 'required|string|max:250|unique:clients,id,105',
)  

When the update method is executed, the The name has already been taken. response is returned during the validation.

I realise this is a well-discussed topic, but believe I am conforming to the correct approach. Can someone point out the error in my logic, please?

Note: This is running on Laravel 5.8.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2M24dSo
via IFTTT

Images not getting displayed in laravel blade view

I'm trying to display multiple images from public folder to laravel blade view. But its not getting displayed.

Here is my view code.

<div class="card-body">
  <table class="table">
   <thead>
     <th>Image</th>
     <th>Title</th>
   </thead>
   <tbody>
      @foreach($posts as $post)
       <tr>
         <td><img src="" width="60px" height="60px" alt=""></td>
         <td></td>
       </tr>
      @endforeach
   </tbody>

  </table>

</div>

Its anyway showing title. I thought it may be an issue with url so i tried possible urls to see the image. But this is the most accurate one

<td><img src="http://127.0.0.1:8000/posts/TNL0RZhSi0zkmdBS3IAZodv0dqNEeVT4LbJ6GJk2.jpeg" width="60px" height="60px" alt=""></td>

So most possibly the issue is Public folder is not accessble. But i have tried pup artisan storage:link Itried every possible answer in SO,but no luck

Laravel Framework 5.8.38



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2znBKDW
via IFTTT

Spatie Medialibrary Custom Custom Directory As Prefix

I am using spatie/laravel-medialibrary:8.0.

When I uploaded file, it was saved in storage/public directory.

1/filename.file_extension, 2/filename.file_extension...

I think 1, 2... are ids of files.

Is there any way to put different prefix directory according to user?

For example, I want to put like this.

public/storage/user_id/1/filename.file_extension, 

I searched about it but couldn't find exact answer,

Can anyone help me?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TFsYYu
via IFTTT

Can't get user status as int

ErrorException : Object of class App\People could not be converted to int

$check_status = People::select('payment_status')->find($request->people_id);
if ($check_status == 0) {
    return 'active';
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3gmfUB7
via IFTTT

Check collection exist

I have this code:

@foreach($subCategories as $subCategory)
                                <tr data-id="" id="" class="sortItem">
                                    <td class="text-left">
                                        {!! Str::limit($subCategory->category_name, 80, '...') !!}
                                        <p class="text-muted"></p>
                                    </td>

                                    <td class="text-center">

                                        @if ($subCategory->enable == 1) <span
                                            class="label font-weight-bold label-lg  label-light-success label-inline"><i
                                                class="ft-thumbs-up"></i> aktywny </span> @else
                                            <span
                                                class="label font-weight-bold label-lg  label-light-danger label-inline"><i
                                                    class="ft-thumbs-down"></i> nieaktywny </span>
                                        @endif

                                    </td>

                                    <td class="text-center">
                                        <a href=""
                                           class="badge badge-primary badge-md h-30px"><i
                                                class="ft-aperture"></i> Rozwiń</a>

                                        <a href=""
                                           class="badge badge-info badge-md h-30px"><i
                                                class="ft-aperture"></i> Edytuj</a>
                                        <form method="post"
                                              action=""
                                              class="d-inline-block" onSubmit="showAlert();{return false;}">
                                            @method('DELETE')
                                            
                                            <input type="submit" class="removeBtn"
                                                   value="Usuń">
                                        </form>
                                    </td>
                                </tr>
                        @endforeach

Sometimes there is an error in the above code:

Trying to get property 'id' of non-object (View: /var/www/resources/views/admin/categories/subcategory_list.blade.php)

When I debug, problem is when in my $subCategory I have:

App\Models\Category {#487 ▼
  #quarded: array:1 [▶]
  #fillable: array:11 [▶]
  +timestamps: false
  #connection: "mysql"
  #table: "categories"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:12 [▶]
  #original: array:12 [▶]
  #changes: []
  #casts: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
  #pending: null
  #moved: false
}

When I have in debug:

Kalnoy\Nestedset\Collection {#487 ▼
  #items: array:3 [▼
    0 => App\Models\Category {#1423 ▶}
    1 => App\Models\Category {#1422 ▶}
    2 => App\Models\Category {#1426 ▶}
  ]
}

This code work fine.

How can I secure my foreach function so that it doesn't display an error?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c5j4WL
via IFTTT

Integration Laravel with database.net - html tags visible in row

I use this component in my project: yajra/laravel-datatables

I have controller:

public function dataTable(Request $request)
    {
        if ($request->ajax()) {
            return Datatables::of($this->model->all())
                ->addIndexColumn()
                ->editColumn('enable', function ($row) {
                    if ($row->enable == 1)
                        return '<span class="label font-weight-bold label-lg  label-light-success label-inline">aktywny</span>';
                    else return '<span class="label font-weight-bold label-lg  label-light-danger label-inline">nieaktywny</span>';

                })
                ->editColumn('name', function ($row) {
                    return Str::limit($row->name, 80, '...');
                })
                ->addColumn('action', function ($row) {
                    $btn = '<a href="' . route('product.edit', ['id' => $row->id]) . '" class="removeItem"><i class="far fa-edit"></i></a> ';
                    $btn .= '<a href="' . route('product.destroy', ['id' => $row->id]) . '" class="removeItem"><i class="removeItem far fa-trash-alt"></i></a> ';

                    return $btn;
                })
                ->rawColumns(['action'])
                ->make(true);
        }
    }

and html:

 <table class="table table-bordered data-table    ">
                        <thead>
                        <tr class="resources">
                            <th>ID</th>
                            <th>Nazwa produktu</th>
                            <th>Status</th>
                            <th width="100px" class="text-center">Akcja</th>
                        </tr>
                        </thead>
                        <tbody class="data-table-center">
                        </tbody>
                    </table>
                </div>
                <div class="datatable datatable-bordered datatable-head-custom" id="kt_datatable"></div>




$(function () {
            var table = $('.data-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: "",
                language: {
                    url: ""
                },
                iDisplayLength: 50,
                render: function (data, type, row) {
                    return data;
                },
                columns: [
                    {data: 'DT_RowIndex', name: 'DT_RowIndex'},
                    // {data: 'id', name: 'id'},
                    {data: 'name', name: 'name'},
                    {data: 'enable', name: 'enable'},
                    {data: 'action', name: 'action', orderable: false, searchable: false},
                ]
            });
        });

In the status (enable) column I see this html instead of the final string. As if a blade would replace such html badly.

My result:

<span class="label font-weight-bold label-lg label-light-success label-inline">aktywny</span>

Prview: https://ibb.co/6tXdH65

How can I fix it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2X48FpK
via IFTTT

How do I use a groupBy() with join in laravel 5

I have a little challenge here, I want to get orders from my orders table grouping by created_at field and aggregating the amount for each date. The amount is from another table (products) called price. Order table has a product_id as foreign key. I then did this

        $ord = DB::table('orders')
            ->join('products', 'orders.product_id', '=', 'products.id')
            ->select(DB::raw('DATE(orders.created_at) as created_at'),
                'products.price',
                //DB::raw('sum(products.price) as amount')
            )->orderBy('orders.created_at', 'desc')
            ->get();
        $ord->groupBy('created_at');
        return $ord;

The issue here is that when I uncomment the //DB::raw('sum(products.price) as amount'), it throws me an error Syntax error or access violation: 1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column. Without it, I have a result like this

[{"created_at":"2020-05-26","price":"950"},{"created_at":"2020-05-18","price":"4000"},{"created_at":"2020-05-18","price":"4000"},{"created_at":"2020-05-12","price":"320"}]

But from here, two records on the 18th with 4000 should aggregate to 8000 for that date alone, that's how I want it. Any useful help on this will be greatly appreciated



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2X2x535
via IFTTT

.env file missing! You forgot to upload the .env file in Laravel

server.php

<?php
    $uri = urldecode(
        parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
    );
    if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
        return false;
    }
    require_once __DIR__.'/public/index.php';

public/index.php

<?php
    if(!file_exists('../.env')){
        $GLOBALS["error_type"] = "env-missing";
        include('error_install.php');
        exit(1);
    }

    if (version_compare(PHP_VERSION, '7.2.5') < 0){
        $GLOBALS["error_type"] = "php-version";
        include('error_install.php');
        exit(1);
    }
    changeEnvironmentVariable();

    function changeEnvironmentVariable()
    {

        $path = '../.env';
        if (file_exists($path)) {
            $current = file_get_contents($path);
            $original = [];
            if (preg_match('/^DB_PASSWORD=(.+)$/m', $current, $original)) {
                $current = preg_replace('/^DB_PASSWORD=.+$/m', 'DB_PASSWORD="' . $original[1] . '"', $current);
                if (strpos($original[1], '"') === false) {
                    file_put_contents($path, $current);
                }
            }
        }
    }

    require __DIR__.'/../vendor/autoload.php';

    $app = require_once __DIR__.'/../bootstrap/app.php';

    $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

    $response = $kernel->handle(
        $request = Illuminate\Http\Request::capture()
    );

    $response->send();

    $kernel->terminate($request, $response);

I am trying to deploy my laravel project on server but I am unable to run when I hit for example https://example.com then it shows directory structure I have checked all but can't find error and when I run server.php file with domain then it shows .env file missing! You forgot to upload the .env file. where I have already a .env file in my root dir and I also tried to replace it with .evn.example but it remain show directory structure.

I don't understand where am I doing wrong? Please help me to solve this.

Thank you



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ZGlsR5
via IFTTT

Laravel and DataTables.net

I am beginner in Laravel. I use in my project Laravel 7. I use yajra/laravel-datatables in my project.

I have this code:

<table class="table table-bordered data-table    ">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>Tytuł</th>
                            <th>Status</th>
                            <th width="100px">Akcja</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>


$(function () {
            var table = $('.data-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: "",
                columns: [
                    {data: 'DT_RowIndex', name: 'DT_RowIndex'},
                    // {data: 'id', name: 'id'},
                    {data: 'title', name: 'title'},
                    {data: 'enable', name: 'enable'},
                    {data: 'action', name: 'action', orderable: false, searchable: false},
                ]
            });
        });

and controller:

public function tabelka2(Request $request)
    {
//        return Datatables::of(Page::query())->make(true);
        if ($request->ajax()) {
            $data = Page::get();
            return Datatables::of($data)
                ->addIndexColumn()
                ->addColumn('action', function($row){

                    //$btn .= '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm">View</a>';
                    $btn = '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm"></a> ';
                    $btn .= '<a href="javascript:void(0)" class="edit btn btn-primary btn-sm"></a> ';



                    return $btn;
                })
                ->rawColumns(['action'])
                ->make(true);
        }
    }

It's work fine.

  1. How do I search for columns other than title, enable? I need to search for description and keywords.
  2. If enable = 1 - I would like to display "active". Otherwise "inactive"
  3. I would like to "pack" the title value in: ...])}} "> description

Anyone know how to do this? Please help



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TGj0pX
via IFTTT

lundi 25 mai 2020

Merge Cells in laravel CSV Export

How to merge two or more cells in laravel csv export ?? I am using mergeCells function for it.. but it hides the data of the merged cells . Can anyone please help me ? Thanks for your precious time



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TG30nR
via IFTTT

How to Sum last value of all users in database

I have a database with different users, with an amount column....all this user all have different value in their amount colume, but i want to pick all the last amount for each user and sum it.

i tried it like this but game an error

 $returned =  DB::table('sales')->sum('returned')->last();

pls, i dont want the total sum of the amount column....because some users have more than one amount, so i want to pick the last one for each user and sum it



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3c45tyG
via IFTTT