Category : laravel

I’m using Laravel 5.8 and I want to download data from view with LaravelExcel. Here is my Export Class: namespace AppExports; use AppMemberStudent; use IlluminateContractsViewView; use MaatwebsiteExcelConcernsFromView; use MaatwebsiteExcelFacadesExcel; class StudentExportView implements FromView { /** * @return IlluminateSupportCollection */ public function view(): View { return view(‘admin.students.custom’, [ ‘students’ => Student::take(1)->get(), ‘customs’ => Student::take(1)->get(), ]); } ..

Read more

This is your docker-compose file to add "Phpmyadmin" you just have to the following commands that I will leave in "answer" For more information: https://laravel.com/docs/sail version: "3" services: laravel.test: build: context: ./vendor/laravel/sail/runtimes/8.0 dockerfile: Dockerfile args: WWWGROUP: "${WWWGROUP}" image: sail-8.0/app ports: – "${APP_PORT:-80}:80" environment: WWWUSER: "${WWWUSER}" LARAVEL_SAIL: 1 volumes: – ".:/var/www/html" networks: – sail depends_on: – ..

Read more

"select users.id, users.name, users.avatar, users.email, messages.message, messages.is_read, messages.msg_to, messages.msg_from, messages.created_at, max(messages.created_at) as max_created_at from users LEFT JOIN messages ON users.id = messages.msg_from and is_read = 0 and messages.msg_to = " . Auth::id() . " where users.id != " . Auth::id() . " AND users.id IN ( SELECT friends.friend_id from friends WHERE friends.user_id = " . ..

Read more

i am having the error stated above, and here is the copy log php artisan db:seed BadMethodCallException Call to undefined method AppModelsCategory::factory() at vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50 46▕ * @throws BadMethodCallException 47▕ */ 48▕ protected static function throwBadMethodCallException($method) 49▕ { ➜ 50▕ throw new BadMethodCallException(sprintf( 51▕ ‘Call to undefined method %s::%s()’, static::class, $method 52▕ )); 53▕ } 54▕ ..

Read more

need to join two data and compile to show in datatable but i dont know what is wrong in my code controller $data = DB::table(‘items’) ->join(‘shipments’, ‘shipments.shp_no’,’=’,’items.shp_no_for_it’) ->select(‘items.it_arabic_name’, ‘shipments.shp_destination_shipping_fees’) ->get(); return Datatables::of($data) ->make(true); ajax columns: [ {data: ‘items.it_arabic_name’, render: function ( data, type, row ) { return row.items.it_arabic_name + ‘ ‘ + row.shipments.shp_destination_shipping_fees; } }] ..

Read more

I have this code: $user = User::updateOrCreate([ ’email’ => $employee->email, ], [ ‘username’ => $employee->username, ‘password’ => bcrypt("123456"), ‘first_name’ => $employee->first_name, ‘last_name’ => $employee->last_name, ]); I want to add a condition that if record exists, it shouldn’t update: ‘password’ => bcrypt("123456"), How do I achieve this? Thanks Sourc..

Read more

Would like to create a history in Laravel 8 when a change has occurred when saving a record against (when updating). This history I would like to save in the database. Is there a solution with Laravel 8 or do you have a tip for me? Sourc..

Read more

I am editing the next error while printing a model content on my blade.php view: And this is how i’m trying to use it on my view: blade.php <div class="form-group"> <label for="color">انتخاب رنگ</label> @if(!$product->colors) <div id="showColors"> </div> @else <div class="row no-gutters mb-1"> <div class="col-md-3"> <label for="color_name" class="ml-1">نام رنگ:</label> <input type="text" id="color_name" name="color_name[]" class="form-control w-auto d-inline" ..

Read more

I am redirecting to a named route in Laravel 7 and instead of the route being redirected it returns the user to the previous page. Controller return redirect()->route(‘NAMEDRoute’)->with("Information", $information[0]); web.php Route::get(‘/x/y’, "[email protected]")->name(‘NAMEDRoute’); This just returns me to the route I was on before, I have tested other routes that also work but the function that ..

Read more

I am integrating Razorpay API to my Web App coded in PHP Laravel. I have 2 files – RazorpayController.php public function create($profile = null, Request $request){ $details = json_decode($request->details); return view(‘profile.payment.razorPay’, [‘profile’ => $this->profile, ‘details’ => $details, ‘total’ => $total, ‘data’ => $data]); } public function verify($profile = null, Request $request){ $orders = [‘details’ => ..

Read more

In Laravel-8 Maatwebsite Excel import, I am implementing Custom ID Generator from helper. I have this code in the Maatwebsite ExcelImport: protected $companyId = Auth::user()->company_id; public function getID(){ return IdGenerator::select(‘id’) ->where(‘company_id’, $this->companyId)->first(); } I got this error: Constant expression contains invalid operations This is highlighted: protected $companyId = Auth::user()->company_id; Sourc..

Read more

public function createall() { $users = User::orderBy(‘id’, ‘ASC’) ->where(‘server’, ‘Demo’) ->where(‘enable’, ‘1’) ->where(‘mt4_account’, ‘!=’, 0) ->take(4) ->get(); foreach ($users as $user) { $server = Server::where(‘Serverdesc’, $user->server)->first(); $post = [ ‘server’ => $server->serverdesc, ‘api_key’ => ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’, ‘login’ => intval($user->mt4_account), ]; $datapost = json_encode($post); // initialize cURL $ch = curl_init(); // set options curl_setopt($ch, CURLOPT_URL, "http://xxxxxxxxxxxxxxxxx/closetrades"); curl_setopt($ch, ..

Read more

I want to pass an additional parameter from controller to collection resource, Please have a look at the following code, I don’t know why It’s not working. I might be doing something wron here, please help Controller $batchStudents = $batch->students->except($batch->host->id); $batchStudents->test = ‘This is testing’; $students = UserCollection::collection($batchStudents); Collection: class UserCollection extends JsonResource { return ..

Read more

so I’m relatively new to laravel and am trying to understand it. So far it has been good but I’ve been stuck at an error for a while now so any help would be appreciated. I’m trying to follow along with a youtube tutorial (not sure if links are allowed) and this is what I’m ..

Read more

I’m creating a SNS app, in which User and Post are in many-to-many relationship, with a pivot table Favorite. Is there way to fetch all posts you didn’t faved? $posts = Post::wherehas("users",function($q)use($your_id){ $q->where(‘user_id’, ‘!=’, $your_id); })->orDoesntHave(‘users’)->get(); return $posts; The above method was what I came up with, but it seemed not to work when more ..

Read more