If I use the following:
Artisan::call('routes')
It returns 0.
I was hoping to parse the same routes that appears when I run php artisan routes from CLI.
Has anyone tried this with success?
You dont need artisan - just use the routes class itself:
<table>
<tr>
<th>Routes</th>
</tr>
#foreach(Route::getRoutes() as $name => $route)
<tr>
<td>{{ $name }}</td>
</tr>
#endforeach
</table>
Related
Im trying to make a list with game developers, and when you click on one of them you can see the games they have made. I only dont know how to get further....
This is what i have now:
Index.blade.php:
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col">Naam</th>
<th scope="col">Opgericht in:</th>
</tr>
</thead>
<tbody>
#foreach($gamedevs as $gamedev)
<tr>
<td>{{ $gamedev['id'] }} </td>
<td>{{ $gamedev['naam'] }}</td>
<td>{{ $gamedev['opgericht'] }}</td>
</tr>
#endforeach
</tbody>
I already tried some methods like these:
href="{{route('games.show', ['id'=>$gamedev->id])}}
and
href="/games/{{$gamedev['id']}}
listcontroller.php
public function index()
{
$gamedevs = Gamedevs::all();
return view("index", [ 'gamedevs' => $gamedevs]);
}
public function show(Gamedevs $gamedevs)
{
$gamedevs = Gamedevs::where($gamedevs)->first();
return view('pages.games.show')->with('Gamedevs',$gamedevs);
}
Never did this before.. so hope im on the right way :)
Laravel controller methods like show will use service container to resolve all the parameters you define there. Since you define a model, laravel will automatically find the one corresponding with explicit model binding.
So you wont have to write another query to show your Gamedev:
public function show(Gamedevs $gamedevs)
{
return view('pages.games.show')->with('Gamedevs',$gamedevs);
}
Sample route in web.php
Route::get('/games/{dev_id}','listController#show');
Sample Method in your listController.php
public function show($gamedevs)
{
#let's say your $gamedevs is your devs id so target their id's
$devs = Gamedevs::where('id',$gamedevs)->first();
return view('pages.games.show')->with([
'Gamedevs'=>$devs
]);
}
In your view
href="/games/{{$Gamedevs->id}}
I'm having trouble on passing application_id from application#edit controller to addapplication#index controller. Please help me.
application#edit controller
$application->application_id = $request->application_id;
$application->save();
return redirect(route('addapplication.index'))->with('application_id',$request->application_id);
addapplication#index controller
$application_id = Session::get('application_id');
$applications = addapplication::where('application_id', $application_id)->get();
return view('user.addapplication.index',compact('applications'));
blade.php
#foreach ($applications as $application)
<tr>
<td>{{ $loop->index +1 }}</td>
<td>{{ $application->application_id }}</td>
<td>{{ $application->created_at }}</td>
<td>{{ $application->surname }}, {{ $application->firstname }} {{ $application->middlename }}</td>
<td><img src = {{ asset('assets/img/eye.ico') }}/>
</td>
</tr>
#endforeach
I'm getting this error:
Missing required parameters for [Route: addapplication.edit] [URI:
addapplication/{addapplication}/edit]. (View: D:\path\index.blade.php)
here is my route.php
Route::resource('application', 'ApplicationController');
Route::resource('addapplication', 'AddApplicationController');
Please help me. Thank you!
You have to use like this
{{route('addapplication.edit',['addapplication'=>$application->id])}}
The route helper requires an array as the secondary argument.
{{ route('addapplication.edit', ['addapplication' => $application->id])}}
You can figure out the required key (in any scenario) by using the artisan route:list command and looking at the values between the curly braces in the URI column.
In your case the route should look like this:
/addapplications/{addapplication}/edit
I have this code to view all invoices in my page:
#foreach ($user->invoices() as $invoice)
<tr>
<td>{{ $invoice->date()->toFormattedDateString() }}</td>
<td>{{ $invoice->total() }}</td>
<td>
Download
</td>
</tr>
#endforeach
However, the line $invoice->date()->toFormattedDateString() gives an error:
DateTime::__construct(): Failed to parse time string (#) at position 0 (#): Unexpected character
I just followed all instructions in the Laravel Cashier (Billing) website and I am getting this error. I have tried two versions of Laravel (5.8 and 5.5) and two Laravel Cashier versions (8.0 and 7.0). All tests have the same date issue.
I have added the correct migrations fields. This is how I insert/add subscription to my database:
$user = Auth::user();
$user->newSubscription('eat', 'eat_monthly')->create($request->stripeToken);
instead of {{ $invoice->date()->toFormattedDateString() }}
Can you try {{ $invoice->created_at->toFormattedDateString() }} ?
Stripe has changed date parament to created works.
Use this way:{{ $invoice->created }}
I Building an Affiliate System for my Users. Registration with ID works fine and save all correct in my DB, but i cant see any Referrals that use my URL ID for Registration in my Example Blade.
Any one cant find the Error?
Controller:
$referal_id = $user->id;
$referer_id = $request['referal_id'];
$referalUserData = [
'referer_id' => $referer_id,
'referal_id' => $referal_id,
];
$insert = ReferralUser::insert($referalUserData);
Blade:
<tr>
<th>#</th>
<th>User Id#</th>
<th>User Name</th>
<th>Registration Time</th>
</tr>
</thead>
<tbody>
#if(!empty($referalUser))
#foreach($referalUser as $referData)
<tr>
<th scope="row">{{$referData->id}}</th>
<td>{{$referData->referal_id}}</td>
<td>#for($i=0;$i<count($referData['names']);$i++) {{$referData['names'][$i]['name']}} #endfor
</td>
<td> {{$referData->created_at}}<br/> <span class="label label-primary">
{{Carbon\Carbon::createFromTimestamp(strtotime($referData->created_at))->diffForHumans()}} </span> </td>
</tr>
#endforeach
#else
<div class="alert alert-noreferals">
<strong></strong><span>No referrals!</span>
</div><br/><br/>
#endif
Ignore the created_at Timestamp.
Thanks
Did you convert the $request object to an array?
$request['referal_id'];
That looks suspicious. Typically you would use
$request->input('referal_id')
or via dynamic properties
$request->referal_id
To access a given value.
Are you getting an error? Anything in the log files?
We have a project upgraded from laravel v 5.1 to v 5.4
and many issues and bugs appear after upgrade anyway have this one
Trying to get property of non-object for index.blade.php
and this is the code
<tbody>
#foreach($routeFEmails as $routeFEmail)
<tr>
<td>{{ $routeFEmail->id }}</td>
<td>{{ $routeFEmail->routeF->id }} ({{ $routeFEmail->routeF->vessel_name }})</td>
<td>{{ $routeFEmail->creator->type }}: {{ $routeFEmail->creator->first_name }} {{ $routeFEmail->creator->last_name }}</td>
<td>{{ $routeFEmail->status }}</td>
<td>{{ $routeFEmail->created_at->format('Y-m-d H:i') }}</td>
</tr>
#endforeach
</tbody>
i check model and no value from what mention is null no NULL
i did also
php artisan cache:clear
php artisan route:clear
php artisan view:clear
and this is a function in co controller
public function index()
{
$routeFEmails = RouteFEmail::orderBy('id', 'desc')->paginate(10);
return view('backend.route_f_emails.index', compact('routeFEmails'));
}
HOW I CAN FIX THIS ? :(
Your problem is with compact(), Return type of compact() is array [Read Here], so when you are passing compact('routeFEmails') it is converting object to array.
In index.blade.php you are accessing values of $routeFEmails as object. So you can try one of below solutions.
Solution 1
Write <td>{{ $routeFEmail['id'] }}</td> instead of <td>{{ $routeFEmail->id }}</td>
OR
Solution 2
Write
return view('backend.route_f_emails.index', ['routeFEmails'=>$routeFEmails]);
instead of
return view('backend.route_f_emails.index', compact('routeFEmails'));
trying to get a property on a non object means that the $routeFEmail is not an object not that some of it's properties like id is null.
Also the part
$routeFEmail->routeF
could be null ( My guess that the problem is there)
you can skip it with
#if( !is_null($routeFEmail->routeF) )
write something
#endif
or even dd if it is null