Questions tagged [laravel-10]

Laravel 10 is the current stable version of the open-source PHP web framework created by Taylor Otwell. It was released on February 14, 2023. Please use the [laravel] tag for general Laravel-related questions.

492 questions
42
votes
9 answers

Errors "This action is unauthorized." using Form Request validations in Laravel

I make some gate like this: Gate::define('update-post', function ($user, Post $post) { return $user->hasAccess(['update-post']) or $user->id == $post->user_id; }); I checked my database and it has update-post access and the user id is same as…
Ying
  • 1,282
  • 4
  • 19
  • 34
31
votes
3 answers

laravel/framework[v10.0.0, ..., v10.0.3] require composer-runtime-api ^2.2 -> found composer-runtime-api[2.1.0] but it does not match the constraint

When trying to install laravel 10, I am getting this error- laravel/framework[v10.0.0, ..., v10.0.3] require composer-runtime-api ^2.2 -> found composer-runtime-api[2.1.0] but it does not match the constraint.
Yeasir Arafat
  • 1,425
  • 1
  • 13
  • 28
7
votes
0 answers

Laravel 9 and 10 is using x15 ram than previous version (probably due to SANCTUM), how to opitmize?

I have 3 Laravel applications, one running on Laravel 6 and 2 running on Laravel 8. They all uses Vue and JWT auth from tymondesigns, and I've plan to upgrade them all to Laravel 10. But after I successfully rebuilt one of my application to have…
SymmetricsWeb
  • 586
  • 6
  • 20
4
votes
5 answers

Larastan complains about collection methods paramaters after upgrading to Laravel 10

After upgrading to Laravel 10 I'm having hard times with Larastan errors. The following code which was perfectly fine until 1 hour ago: return $this->articleRepository->getDefaultArticles($organizationId) ->toBase() ->map(function (Article…
Fabio Sasso
  • 145
  • 1
  • 12
4
votes
3 answers

cannot perform raw query with DB::select(DB::raw()) after updating to laravel 10

after updating to laravel 10, i cant perform raw query like this: $statement = 'SELECT'; foreach ($tables = collect(availableTables()) as $name => $table_name) { if ($tables->last() == $table_name) { $statement .= "( SELECT…
arya_la
  • 399
  • 2
  • 10
3
votes
2 answers

Laravel 10 - API Key in .env file is not recognized

I am using Laravel Framework 10.15.0. I am trying to load my API-Keys the following way: $apiKeyOpenAI = env('OPENAI_API_KEY'); $client = OpenAI::client($apiKeyOpenAI); In my .env file the api key is clearly…
Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
2
votes
2 answers

How to update Laravel Eloquent column cast as collection

I am using Laravel 10. I am utilizing casting for a JSON column in the following manner: namespace App\Models; use Illuminate\Database\Eloquent\Model; class Item extends Model { protected $casts = [ 'meta' => 'collection', // here …
Denis
  • 322
  • 1
  • 4
  • 15
2
votes
1 answer

Custom class in laravel 10 not found

I have created a custom class in laravel 10 located in: App\Helpers\CompletedOrders The class contain this code:
Cod3rMax
  • 23
  • 4
2
votes
0 answers

Laravel 10 Disable OPTIONS Method

I have developed web application using Laravel 10 and nginx, I want to allow only post method for specific route Route::post('/otpgen', 'App\Http\Controllers\controller@otpgen'); I have following code in my app\Exception\Handler.php public function…
user3782114
  • 542
  • 2
  • 7
  • 22
2
votes
1 answer

Laravel 10 DB:raw incorrectly putting backticks around sql functions

In Laravel 9 we had raw sql lines such as the following: ... ->whereIn(DB:raw('concat(a_col, b_col)'), function ($query) { ... In order to be compatible with Laravel 10 we changed such lines to use the getValue…
AndyW
  • 985
  • 3
  • 10
  • 21
2
votes
3 answers

Auth::check return false in middleware with Laravel-10

I read 25 Stackoverflow questions, solutions, and some blogs, also watch some Youtube videos on this problem. But I did not get a solution for this problem. I tried this so many times. Expecting someone's help. Auth file 'defaults' => [ 'guard'…
Abdul Aziz
  • 35
  • 6
2
votes
2 answers

Retrieving single value data at Blade via Repository GONE WRONG

I'm using Laravel 10 and I have made a table named pages which stores the all static pages field data of website. Here is the table: Now in order to retrieve this data, at the Controller I added this: use App\Repositories\PageRepository; use…
Pouya
  • 114
  • 1
  • 8
  • 36
2
votes
0 answers

Hide Laravel API url access from public view

I have a Laravel 10 project that has both the front end and the back end within the same project. This website renders information from a database. Everything works as expected. I have two route files web.php and api.php I have the following API…
rfadeout
  • 21
  • 2
2
votes
1 answer

Laravel 10 - mutators and accessors don't work

I have a problem with the accessors and mutators in laravel 10. In my first project, they work, but in the second, they don't. Model protected function name(): Attribute { return Attribute::make( get: fn(string $value) =>…
2
votes
0 answers

I am having a CORS error when getting image with Laravel 10

I have an API with Laravel 10 and I am trying to get an image I have saved in the public/images folder. This is my function in the controller: public function show() { $imageUrl = asset('images/myimage.png'); return…
malany_tr
  • 21
  • 2
1
2 3
32 33