Category : variables

This is my Controller Session variable generated in set_value function are not accessible inside function get_value. This code works fine on my localhost, but not working on server. All session related files are same are laravel documentation. Laravel version is 7. public function set_value(Request $request){ session_start(); Session::put(‘name’, ‘Hello World’); } public function get_value(){ $data = ..

Read more

var_export($res) is an array as below. array(0 =>(object) array(‘user’ => NULL, ‘courseId’ => 18,), 1 =>(object) array(‘user’ =>(object) array(‘id’ => 1, ‘name’ => ‘admin’, ‘files’ => NULL,), ‘courseId’ => 1,), ) At every index in this array, i need to calculate count using the courseId and add a new item called count to every index. ..

Read more

I am working on this web app (Laravel 8) in which users can choose their color themes. Basically, to make it simple, let’s say each user can choose their primary_color. On home page (which does not need authentication), the primary_color will come from config (whether user is authenticated or not). On authenticated pages, the primary_color ..

Read more

I want to display order_details table on web, but @foreach loop says Undefined variable $order_details Here is my @foreach loop @foreach($order_details as $order_detail) <tr> <td>{{$order_detail->product_id}}</td> <td>{{$order_detail->name}}</td> <td>{{$order_detail->phone}}</td> </tr> @endforeach My order controller contains this: public function show(Order $order) { $order_details=Order_Detail::all(); return view(‘orders.index’,[‘order_details’ => $order_details]); } Sourc..

Read more

Is there a way to use different bootstrap variables by using custom _variables file, selected upon some .env variable of Laravel 8? something like, in app.scss: if APP_VARIABLE = 1, then @import custom1_variables.scss if APP_VARIABLE = 2, then @import custom2_variables.scss and so on… Would only want to select different _variables file, not the main app.scss ..

Read more

I have faced the issue for Undefined variable: images – Error message. Please check the below codes. Please support me. ‘Route::get(‘partials/recent-gallery’,’[email protected]’);’ ‘public function recentview() { $images = ImageGallery::all(); return view(‘partials.recent-gallery’, [‘images’ => $images]); }’ —Home Page ‘@include(‘partials/recent-gallery’)’ —- View page—–recent-gallery.blade.php—— ‘@if($images->count()) @foreach($images as $image) {{ $image->galley_image }} @endforeach @endif’ ——————-ERROR————— $images is undefined Sourc..

Read more

I have a function in helper.php: public static function getFristImageSearch($slug) { $slug = str_replace("-", " ", $slug); $image = Images::select(‘thumbnail’)->where( ‘metakeywords’,’LIKE’, ‘%’.$slug.’%’ ) ->where(‘status’, ‘active’ ) ->groupBy(‘id’) ->orderBy(‘DATE’, ‘desc’ ) ->first(); if( isset( $image ) ) { return $image->thumbnail; } else { return ""; } } now I want to call this function in Javascript ..

Read more

Hello I am using laravel Yajra datatables, the matter is that I have a 2 variables created in a function with the name of the id. This is all the code <?php namespace AppHttpControllersDatatables; use AppUser; use CarbonCarbon; use YajraDataTablesDataTables; use AppReportes; class ReportesDatatable { public function ReportesDatatable() { $reportes = Reportes::get(); return Datatables::of($reportes) ->editColumn(‘reportante’, ..

Read more

I’m trying to have a button to set a variable, then return the same site including the variable with the value. I’ve tried this, and have no idea how to do this when it does not work. public function printRecords() { $time = request(‘dateBtn’); return redirect(‘/admin’)->with(‘dato’, $time); } That’s the UserController <form action="/booking-date" method="get"> <button ..

Read more

I have this extremely simple code snipped in my controller, which always did its job of getting a php varaible from URL: URL: wholesaleeventeditions/create?event=36 $wholesaleevent = Input::get(‘event’); if(isset($wholesaleevent)) { $event = $wholesaleevent; } else { $event = null; } Now, after I have migrated to new VPS service, Laravel 8 cannot handle the variable. It ..

Read more

When I initialize a global variable with rand(), get this error on rand(): Constant expression contains invalid operations This is my code: class registerController extends Controller { public $conto = rand(100,999); public function create() { … $conto = $this->conto; … } public function countErrors() { … $conto = $this->conto; } Sourc..

Read more

i work in huge project , i have make relationship between account table and almost all tables, i have to set this in every controller account::find(session("LoggedUser"))->relationship_table(); and it’s very annoying, so is there any way to make it cleaner without repetition like global variable example: //some where global $user = account::find(session("LoggedUser")); //in any controller $user->relationship_table(); ..

Read more

I am trying to pass 2 variables to View Composers like this: public function compose(View $view) { $catalog = Category::with(‘children’)->where(‘parent_id’, NULL)->get(); // if(isset($catalog->img)){ // $cat = Category:: $contents = collect(Storage::disk(‘google’)->listContents(‘sdfJSALSNldKdnslwk230jsd/’, false)); $file = $contents ->where(‘type’, ‘=’, ‘file’) ->where(‘filename’, ‘=’, pathinfo($catalog->img, PATHINFO_FILENAME)) ->where(‘extension’, ‘=’, pathinfo($catalog->img, PATHINFO_EXTENSION)) ->first(); $catimg = isset($file[‘path’])?(Storage::disk(‘google’)->exists($file[‘path’])?Storage::disk(‘google’)->url($file[‘path’]):NULL):NULL; }; // return $view->with([‘catalog’ => $catalog, ..

Read more

public function Query() { $total= User::get(‘e_id’); // dd($total); foreach($total as $totals){ [$year, $month] = explode(‘-‘, $this->month); dd($totals); $s= User::whereMonth(‘date’ , $month)->whereYear(‘date’ , $year)->where(‘e_id’ , $totals)->get()->sum(‘latehours’); dd($s); } // dd($totals); } in this code the variable $totals contain value of ‘e_id’ e.g. "a-2" which it get from form when I dd($totals) it shows value e.g. "a-2" ..

Read more