Lestah

Lestah

Member Since 2 Years Ago

Experience Points
5,480
Total
Experience

4,520 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
22
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
5,480 XP
Sep
17
1 month ago
Activity icon

Replied to Array To String Conversion Feature Test

yes I've but my table expects

"value": "format:date",

so if i did write this code


$attributes = [
            'key' => 'format:date',
            'value' => settings('format:date')
        ];


i will get Failed asserting that a row in the table [settings] matches the attributes {
    "key": "format:date",
    "value": ":human:"
}

Activity icon

Replied to Array To String Conversion Feature Test

Here's what i did on my controller


  /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->service()->store($request->except(['_token']));

        return back();
    }

just the normal array

Activity icon

Started a new Conversation Array To String Conversion Feature Test


/**
     * Add. test pass
     *
     * @test
     * @group  feature
     * @group  feature:setting
     * @group  settings.index
     * @return void
     */
    public function a_user_can_save_preferred_date_format()
    {
        // Arrangements
        $this->withoutExceptionHandling();
        $this->actingAs($user = $this->asNonSuperAdmin(['settings.store', 'settings.preferences']));
        $this->withPermissionsPolicy();

        // Actions
        $attributes = [ 'format:date' => [
            'key' => 'format:date',
            'value' => settings('format:date')
        ]];

        $response = $this->post(
            route('settings.store'), $attributes,
            ['HTTP_REFERER' => route('settings.preferences')]
        );

        // Assertions
        $response->assertRedirect(route('settings.preferences'));
        $this->assertDatabaseHas($this->service->getTable(), $attributes);
    }

I'm not sure on this line


  $response = $this->post(
            route('settings.store'), $attributes,
            ['HTTP_REFERER' => route('settings.preferences')]
        );

I got an error that says ErrorException: Array to string conversion what could be wrong? can someone have an idea thanks

Sep
16
1 month ago
Activity icon

Replied to Laravel Feature Test

here's the route


<?php

Route::namespace('Settings')->prefix('settings')->group(function () {
    Route::get('branding', 'ShowBranding')->name('settings.branding');
    Route::get('preferences', 'ShowPreference')->name('settings.preferences');
});

Route::get('settings', 'Settings\RedirectSettings')->name('settings.index');
Route::post('settings', '[email protected]')->name('settings.store');

Activity icon

Replied to Laravel Feature Test

i tried

$response->assertStatus(302)

it says the response is not a view

Activity icon

Replied to Laravel Feature Test


<?php

namespace Setting\Http\Controllers;

use Core\Http\Controllers\AdminController;
use Illuminate\Http\Request;
use Setting\Services\SettingServiceInterface;

class SettingsController extends AdminController
{
    /**
     * Create a new controller instance.
     *
     * @param \Setting\Services\SettingServiceInterface $service
     */
    public function __construct(SettingServiceInterface $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $settings = $this->service()->all();

        return view('setting::admin.index')->withResources($settings);
    }

Activity icon

Replied to Laravel Feature Test

yes the same error Response status code [302] is not a succesful status code. failed asserting that false is true i think it has something to do with my $response = $this->get(route('settings.index'));

Sep
15
1 month ago
Activity icon

Started a new Conversation Laravel Feature Test

Im trying this test but it says failed asserting that false is true this is just a simple test so user can visit the settings page


/**
     *
     * @test
     * @group  feature
     * @group  feature:setting
     * @group  settings.preferences
     * @return void
     */
    public function a_user_can_visit_the_settings_page()
    {
        // Arrangements
        // $this->withoutExceptionHandling();
        $this->actingAs($user = $this->superAdmin);
        $settings = factory(Setting::class, 5)->create();

        // Actions
        $response = $this->get(route('settings.index'));

        // Assertions
        $response->assertSuccessful()
                 ->assertViewHas('settings')
                 ->assertViewIs('setting::admin.index');
    }

Jun
24
3 months ago
Activity icon

Started a new Conversation Single Action Controller

I'm just trying to convert a closure-based routes to use a single action controller this is my example code

on my routes.php

// Route::get('themes/{file?}', function ($file = null) {
//     $path = base_path(config('path.themes', 'themes').'/'.settings('active_theme', 'default'))."/$file";
//     $fileArray = explode('/', $file);
//     $lastFile = end($fileArray);
//     $extension = explode(".", $lastFile);
//     $fileExtension = end($extension);
//     $isCss = 'css' === $fileExtension ? true : false;

//     if (! in_array($fileExtension, config('downloadables', []))) {
//         return abort(403);
//     }

//     if (\File::exists($path)) {
//         $headers = [
//             'Cache-Control' => 'public',
//             'Content-Type' => 'text/css'
//         ];
//         return response()->file($path, $isCss ? $headers : []);
//     }

//     return abort(404);
// })->where('file', '.*');

Route::get('theme/{file?}', 'FuzzyController')->where('file', '.*')->name('fuzzy-theme');

and on my Controller


<?php

namespace App\Http\Controllers;
namespace Core\Controllers\Assets;

// use App\User;
use App\Http\Controllers\Controller;

class FuzzyController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return View
     */
    public function __invoke(Request $request, $file = null)
    {
        $path = base_path(config('path.themes', 'themes').'/'.settings('active_theme', 'default'))."/$file";
        $fileArray = explode('/', $file);
        $lastFile = end($fileArray);
        $extension = explode(".", $lastFile);
        $fileExtension = end($extension);
        $isCss = 'css' === $fileExtension ? true : false;

        if (! in_array($fileExtension, config('downloadables', []))) {
            return abort(403);
        }

        if (\File::exists($path)) {
            $headers = [
                'Cache-Control' => 'public',
                'Content-Type' => 'text/css'
            ];
            return response()->file($path, $isCss ? $headers : []);
        }

        return abort(404);
        // return view('user.profile', ['user' => User::findOrFail($id)]);
    }

}


then i get this error when running app:serve

Uncaught UnexpectedValueException: Invalid route action: [AssetsController].

can someone explain why i get this invalid route action thanks :D

Apr
21
5 months ago
Activity icon

Replied to Object Of Class Illuminate\Database\Eloquent\Collection Could Not Be Converted To Int

Thanks for responding figure it out i just need to log out as a user to run the test. Sorry for asking this question

Activity icon

Started a new Conversation Object Of Class Illuminate\Database\Eloquent\Collection Could Not Be Converted To Int

it says the error is on my index.blade.php


@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <div class="d-flex align-items-center">
                        <h2>All Questions</h2>
                        <div class="ml-auto">
                            <a href="{{ route('questions.create') }}" class="btn btn-outline-secondary">Ask Question</a>
                        </div>
                    </div>
                </div>

                <div class="card-body">
                    @include('layouts._messages')
                    @foreach($questions as $question)
                        <div class="media">
                            <div class="d-flex flex-column counters">
                                <div class="vote">
                                    <strong>{{ $question->votes }}</strong> {{ str_plural('vote', $question->votes) }}
                                </div>
                                <div class="status {{ $question->status }}">
                                    <strong>{{ $question->answers_count }}</strong> {{ str_plural('answer', $question->answers_count) }}
                                </div>
                                <div class="view">
                                    {{ $question->views . " " . str_plural('view', $question->views) }}
                                </div>
                            </div>
                            <div class="media-body">
                                <div class="d-flex align-items-center">
                                <h3 class="mt-0"><a href="{{ $question->url }}">{{ $question->title }}</a></h3>
                                    <div class="ml-auto">
                                        @can ('update', $question)
                                        <a href="{{ route('questions.edit', $question->id) }}" class="btn btn-sm btn-outline-info">Edit</a>
                                        @endcan
                                        @can ('delete', $question)
                                        <form class="form-delete" method="post" action="{{ route('questions.destroy', $question->id) }}">
                                            @method('DELETE')
                                            @csrf
                                            <button type="submit" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are your sure')">Delete</button>
                                        </form>
                                        @endcan
                                    </div>
                                </div>
                               
                                <p class="lead">
                                    Asked by
                                    <a href="{{ $question->user->url }}">{{ $question->user->name }}</a>
                                    <small class="text-muted">{{ $question->created_date }}</small>
                                </p>
                                {{ str_limit($question->body, 250) }}
                            </div>
                        </div>
                        <hr>

                    @endforeach
                    {{ $questions->links() }}
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


C:\newProjects\htdocs\projectvue\app\Policies\QuestionPolicy.php


 public function delete(User $user, Question $question)
    {
        return $user->id === $question->user_id && $question->answers < 1;
    }

this the first time I've encounter this error what does it mean how to solve it?