RFFRED

RFFRED

Member Since 1 Year Ago

Experience Points
8,620
Total
Experience

1,380 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
61
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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
8,620 XP
Sep
17
2 days ago
Activity icon

Replied to How To Style My Notifications

@snapey

I think there is an issue with

->theme('ck')

when it comes to notifications. The theme is not picked up at runtime I am not expert but after reading the Laravel 8 docs I would expect the theme to be picked up

My solution, for now, is to overwrite the theme set in the config file

            return (new MailMessage)
                ->theme('admin_'.config("mail.markdown.theme"))
                ->subject('Password Reset')
                ->markdown('admin.mail.password.reset', ['url' => $url]);

Mail.php

    'markdown' => [
        'theme' => 'ck',

        'paths' => [
            resource_path('views/vendor/mail'),
            resource_path('views/admin/mail'),
        ],
    ],

(https://laracasts.com/discuss/channels/laravel/mailed-notifications-dont-use-mailmarkdowntheme-setting) Could this bug may have been reintroduced in L8??

Sep
16
3 days ago
Activity icon

Replied to How To Style My Notifications

@snapey

It's definitley not working.

placing the css inside resources/views/html/themes/ck.css does not work

I changed my mail.php config file to

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
            resource_path('views/admin/mail/themes'),
        ],
    ],

I have added my path to the "paths" array variable. I guess Laravel loops through the array elements until it finds a match.

I have tried many configuration and it only works if the CSS file is in resources\views\vendor\mail\html\themes, and the theme has to be set in the config file for it to work.

I ran

php artisan optimize

between every attempts and it only worked when the ck.css file is in resources\views\vendor\mail\html\themes

I created different folders just in case with different ck.css file just in case. None of them got picked up. They were: resources\views\html\themes as suggested by @niush resources\views\themes resources\views\admin\mail\themes

I also changed the config to

'markdown' => [
        'theme' => 'default',

        'paths' => [
        ],
    ],

and that worked. should it though?

Not sure what to try next

Activity icon

Started a new Conversation How To Style My Notifications

Hi,

I am strugling styling my notifications in Laravel 8. My notification keeps appearing with the default CSS formatting.

code in my notification

 return (new MailMessage)
                ->theme('ck')
                ->subject('Password Reset')
                ->markdown('admin.mail.password.reset', ['url' => $url]);

mail.php


    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

My theme file is in resources\views\admin\mail\themes\ck.css

Activity icon

Started a new Conversation What Does This Blade Code Do?

HI,

I am looking at creating my first notification. I have published the laravel-mail components to theme my mails.

php artisan vendor:publish --tag=laravel-mail

Looking through resources\views\vendor\mail\html\layout.blade.php, I can see the following line

{{ $header ?? '' }}

What does it do?

Activity icon

Awarded Best Reply on Laravel/UI - Forgotten Password Issue

Here is the answer.

In ForgotPasswordController, the broker function needs to have the guard passed as a parameter

/**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        //the guard is passed as parameter
        return Password::broker('admins');
    }

For more info, https://medium.com/backenders-club/password-brokers-reset-passwords-on-multiple-tables-in-laravel-73068542925c

Activity icon

Replied to Laravel/UI - Forgotten Password Issue

Here is the answer.

In ForgotPasswordController, the broker function needs to have the guard passed as a parameter

/**
     * Get the broker to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\PasswordBroker
     */
    public function broker()
    {
        //the guard is passed as parameter
        return Password::broker('admins');
    }

For more info, https://medium.com/backenders-club/password-brokers-reset-passwords-on-multiple-tables-in-laravel-73068542925c

Sep
14
5 days ago
Activity icon

Started a new Conversation Laravel/UI - Forgotten Password Issue

Hi

I have been working on integrating Laravel/UI with Laravel 8. I am using a custom guard called "admin" and I have added the authentication controllers in app/Http/Controllers/Admin/Auth. I have also customised the views. I have managed to do the register and the login screens. I am however having issues with sending the link for the forgotten password. I keep getting the message "We can't find a user with that email address."

I have done a bit of digging through the laravel classes and the class responsible for retrieving the user is

/**
     * Retrieve a user by the given credentials.
     *
     * @param  array  $credentials
     * @return \Illuminate\Contracts\Auth\Authenticatable|null
     */
    public function retrieveByCredentials(array $credentials)
    {
        if (empty($credentials) ||
           (count($credentials) === 1 &&
            Str::contains($this->firstCredentialKey($credentials), 'password'))) {
            return;
        }

        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->newModelQuery();

        foreach ($credentials as $key => $value) {
            if (Str::contains($key, 'password')) {
                continue;
            }

            if (is_array($value) || $value instanceof Arrayable) {
                $query->whereIn($key, $value);
            } else {
                $query->where($key, $value);
            }
        }

        return $query->first();
    }

It is located in Illuminate\Auth\EloquentUserProvider

The following line keeps returning a "User" Model but I need to get an "Admin" Model

$query = $this->newModelQuery();

See below the ForgotPasswordController I have customised. I use it to display my view. I also apply the "admin" guard

<?php

namespace App\Http\Controllers\Admin\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    use SendsPasswordResetEmails;


    /**
     * Display the form to request a password reset link.
     *
     * @return \Illuminate\View\View
     */
    public function showLinkRequestForm()
    {
        return view('admin.auth.passwords.email');
    }

    /**
     * Get the guard to be used during password reset.
     *
     * @return \Illuminate\Contracts\Auth\StatefulGuard
     */
    protected function guard()
    {
        return Auth::guard('admin');
    }

}

The above class uses the SendsPasswordResetEmails trait whose purpose is to find the user

SendsPasswordResetEmails which callls sendResetLinkEmail(Request $request)

    {
        $this->validateEmail($request);
       
        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $this->credentials($request)
        );

        return $response == Password::RESET_LINK_SENT
                    ? $this->sendResetLinkResponse($request, $response)
                    : $this->sendResetLinkFailedResponse($request, $response);
    }

$this->credentials($request) Keeps returning NULL as it does not find the user in the DB

I am a bit stuck. Not sure what to do next to fix it...

Sep
10
1 week ago
Activity icon

Started a new Conversation Laravel 8 And Laravel/ui

Hi,

I want to know if it is still fine to use laravel/ui for user authentication in laravel 8 as I am not really interested in JET. Or does laravel 8 provide any authentication option without all the JET stuff?

Aug
12
1 month ago
Activity icon

Replied to Pass Variables To @include

OMG... can't believe I did that... I missed out the .blade

Aug
11
1 month ago
Activity icon

Started a new Conversation Pass Variables To @include

Hi,

I want to pass a variable to a template but I keep getting an error I can not fix

@include('mytemplate', ['var1' => '123'])

mytemplate

{{$var1}}

I get the error

[Vue warn]: Property or method "$var1" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

(found in <Root>)

I am not sure how to ix this as I have not started to use any vue code at all

Jul
28
1 month ago
Activity icon

Started a new Conversation Delegate Tasks To A Service

Hi,

I am trying to refactor some of my code and remove functions I had in a model into some other class. I am not sure if we call that a helper class or a service....

Template model

class Template extends Model
{

    protected $fillable = [
        'name', 'display'
    ];


    public function update_modules_attached($attributes)
    {
	//removes all modules from the pivot table for this template
        $this->remove_all_modules_attached();

	$this->attach_modules();

    	//do lots of extra stuff
        
    }

    public function remove_all_modules_attached()
    {
        $this->template->modules()->detach();
    }

    public function attach_modules()
    {
    	//do lots of extra stuff
    }

    //creates pivot table relationsip
    public function modules(){
        return $this->belongsToMany('RF\RFTemplates\Models\Admin\TemplateModule');
    }
}

Controller

class TemplateController extends Controller
{

    /**
     * Create a new controller instance.
     * 
     * @return void
     */
    public function __construct()
    {
    }


    public function create()
    {

        $template = new Template;

        //selects all the modules available in the system
        $modules = DB::table('modules')->get();

        //initialises the modules attached to the template
        $used_modules = [];

        return view($this->views_path.'templates.create', compact('template', 'modules', 'used_modules'));
    }


    public function store(TemplateStoreRequest $request)
    {

        // Will return only validated data
        $validatedData = $request->validated();
 
        //create record
        $template = Template::create($validatedData);

        //updates the modules attached to the template
        $template->update_modules_attached(['modules_list'=>$request->input('modules-list')]);

        return redirect()->route('admin.templates.index')
                         ->with('success', trans($this->lang_path.'create_templates.success') );

    }

I would like to move the functions not really related to the model such as: "update_modules_attached", attach_modules() from the model to another class. There are a few other functions not listed here making the model class very big and that should really be moved

So I created a new class.

class TemplateManagerService
{

	protected $template;


    /**
     * Create a new instance.
     * 
     * @return void
     */
    public function __construct(Template $template)
    {

    	$this->template = $template;

    }

    public function remove_all_modules_attached()
    {

        $this->template->modules()->detach();

    }

    /**
     * Update the template's modules in the pivot table
     *
     * @param  Array  $attributes
     * @return 
     */
    function update_modules_attached($attributes)
    {

	//removes all modules from the pivot table for this template
        $this->template->remove_all_modules_attached();

     }

I have updated my controller to accept the service


class TemplateController extends Controller
{

    private $templateManagerService;

    /**
     * Create a new controller instance.
     * 
     * @return void
     */
    public function __construct(TemplateManagerService $templateManagerService)
    {

        $this->templateManagerService = $templateManagerService;

    }

    public function create(){
	    //does not change
    }

    public function store(TemplateStoreRequest $request)
    {

        // Will return only validated data
        $validatedData = $request->validated();
 
        //create record
        $template = Template::create($validatedData);

        $this->templateManagerService->remove_all_modules_attached();

        return redirect()->route('admin.templates.index')
                         ->with('success', trans($this->lang_path.'create_templates.success') );

    }

What I do not understand is how to pass my newly created instance of $template to the service.

when I run from the controller,

$this->templateManagerService->remove_all_modules_attached();

How does my service know which instance of template it needs to work with??

Jul
23
1 month ago
Activity icon

Started a new Conversation Editing Robots.txt

Hello,

I would like to edit the robots.txt in my CMS in a textarea input field. I am not quite sure how to access the file and load its content. I am using the laravel filesystem but the public and local drives do not point to the /public folder.

Should I create a new drive pointing to /public? Should I move my robots.txt to the public drive (/storage/app/public)? Should I get the content using PHP file functions (file_get_contents() / file_put_contents)?

I am just not quite sure how to approach this?

thanks

Jul
04
2 months ago
Activity icon

Started a new Conversation Editing Parts Of A Model From Multiple Screen & Logging

Hi,

I have a model called core_settings It has 2 fields. SiteName and Status I have 2 controllers. 1 to go to a screen to edit SiteName and the other one to go and edit the website status (live or maintenance) When saving each screen, the core_settings model's observer triggers the "updated" function where I want to log what has been saved. In both cases the core_settings model has been updated and logging the core settings has been updated is not enough. I need to log which screen has been updated. I do not really want to do it in the controller. Not in the repository either. I though the observer would be a good place to do it. Is it? or is there a better place to do it? Another way of doing what I am trying to do? I guess I can detect the page edited in the observer and log the relevant message.

Jun
29
2 months ago
Activity icon

Replied to Looking For A Some People To Build A CMS

@snapey

Hello,

I have indeed reviewed some of the most popular CMS listed in https://laravel-news.com/laravel-cms-packages . Looking at their respective demos, a couple of them looked good from the surface. Others seems too technical, or very much lacking documentation & examples.

I think my real motivation considering the level I am at, is to create a system with other people who want to learn Laravel with me, and have it mentored by someone who has an idea of how it should be architectured.

I have a pretty good idea of what feature we would need to build and the type of functionalities an end user requires to create a decent website.

I don't want to build something like October CMS. The closest thing I saw that matched my idea was "botble". It offers a lot of feature the vast majority of people would require and is intuitive. October CMS might be good for some people but last time I tried I just did not get it, and I would not think for an instant that any average end-user would understand how to manage it.

So is there a need for a new CMS? Maybe, maybe not... I can't really answer that. I am just looking for a team of people who would like to build a CMS alongside me and learn Laravel.

Jun
28
2 months ago
Activity icon

Started a new Conversation Looking For A Some People To Build A CMS

Hi everyone,

I am looking for some people who would be willing to take part in the development of a Laravel CMS. I initially wanted to build it all myself, but I am at a point where I am struggling to make decisions on some areas of the system and so I thought: " wouldn't it be nice if I could gather a small team and if we could share ideas, knowledge and best practice." Sounds nice.

Now, I am not an expert in Laravel but I have been playing with it for a year. I have 15 years expertise in IT and I have used systems like Drupal, Silverstripe,.... and an old custom CMS which I built a long while ago. Now, it's time to learn something new and Laravel is a nice framework to get my teeth into.

Personally, over the past year, I have been working by myself on a personal Laravel CMS project. The idea was to develop a system whilst learning the Laravel framework, which I did not know at all. I have been doing this after work and in the evening. I went online, going from tutorial to tutorial, reading articles, Youtube videos,.... there is a lot that still escapes me but I am at a point where think it would be nice to get involved with other developers and start on something fresh.

I need people quite driven who have some spare time. I know it is very difficult to commit everyday but if you have a few hours every week, then that's something.

You need to have a reasonable PHP/Mysql level and be able to create models, routes, controllers, databables, forms, middleware, views at a minimum. If you can do all of that, then that's great! Let's have a chat.

I also think it would be ideal if I could also find some people with a bit more experience who could guide us when problems arise.

Let me know if anyone is interested. I am based in Huddersfield in the UK

Jun
18
3 months ago
Activity icon

Started a new Conversation Getting Form Errors In Controller

Hi,

I am building a form with Tabs and if an error is returned, I want to highlight the Tabs that have issues inside them. At the minute, my code does no read the error messsages

    public function edit(Request $request)
    {

        $core_settings = CoreSettings::first();
        
        //checks policy
        $this->authorize('update', $core_settings);

        return view('rf-core-settings::rf-core-settings.core_settings.edit', compact('core_settings'));
  
    }


public function update(CoreSettingsStoreRequest $request)
    {

        //Calls the CoreSettingsStoreRequest where the policy check is done

        $core_settings = CoreSettings::first();  

        // Will return only validated data
        $validatedData = $request->validated();

        //updates the record
        $core_settings->update($validatedData);

        //redirects
        return redirect()->route('admin.dashboard')
                        ->with('success', trans('rf-core-settings::rf-core-settings.core_settings.messages.success_flash'));
    }

When an error occurs, I am redirected to the edit function in the controller and I was wondering if there was a function I could use to fetch my errors based on the code I am using.

I know I can use

$errors = Session::get('errors');

but I was wondering if there was something a bit more refined than going into the session directly.

I have read about bags and I ran little experiment with bags but that did not quite work.

    public function edit(Request $request, Illuminate\Support\ViewErrorBag $view_error_bag)
    {

        $core_settings = CoreSettings::first();
        
        //checks policy
        $this->authorize('update', $core_settings);

        $errors = \Session::get('errors');
        if (!empty($errors)){
              dd($errors);
              dd($view_error_bag);
        }

        return view('rf-core-settings::rf-core-settings.core_settings.edit', compact('core_settings'));
  
    }

The above displayed a bag with errors when using dd($errrors) But no errors in the bag when using dd($view_error_bag);

Any advice?

Jun
17
3 months ago
Activity icon

Started a new Conversation How To Pass Variable To Group Function / Lavary Menu

Hi,

The following code has been written using the lavary/laravel-menu. It feeds from the database where I have a nested tree.

//if the menu does not exist
if (! Menu::exists('DashboardMenu'))
{

	//create the dashboard enu
	Menu::make('DashboardMenu', function($menu){
		
		//loads the menu from the CMS tree. Descendant of Dashboard
		$cms_pages_tree = CmsPage::descendantsOf(2)->toTree();

		//loops items
		foreach($cms_pages_tree as $page)
		{

			$menu->add($page->label, ['route' => $page->route]);
			
			$menu->group(['style' => 'padding: 0', 'data-role' => 'navigation'], function($m){

				foreach($page->children as $child)
				{

					$m->add($child->label);

				}

			});
			
		}
		
	}

}

I have added the notion of 'Groups' to get data displayed in ULs and LIs. However, I do not know how to pass the $page variable (from the loop) into the $menu->group function

		//loops items
		foreach($cms_pages_tree as $page)
		{

			$menu->add($page->label, ['route' => $page->route]);
			
			$menu->group(['style' => 'padding: 0', 'data-role' => 'navigation'], function($m){

				foreach($page->children as $child)
				{

If I do

$menu->group(['style' => 'padding: 0', 'data-role' => 'navigation'], function($m, $page){

I get

ArgumentCountError
Too few arguments to function RF\RFCmsPages\Http\Middleware\GenerateCmsMenus::RF\RFCmsPages\Http\Middleware\{closure}(), 1 passed and exactly 2 expected
Jun
15
3 months ago
Activity icon

Started a new Conversation Yajra/eloquent Datatable Does Not Display Anything For BelongsTo Relationship Fields

Hi,

I have a belongs relationship I would like to display in a Yajrah datatable. I have the table working using DB but I want to get it to work using eloquent.

Working script using DB

 if ($request->ajax()) {

            $data = DB::table('log_activities')
                        ->join('admins', 'log_activities.admin_id', '=', 'admins.id')
                        ->whereIn('type', array('info'))
                        ->select(['log_activities.subject', 'log_activities.type', 'admins.first_name', 'admins.last_name', 'log_activities.created_at'])
                        ->latest();
            
            return Datatables::of($data)
                    ->addColumn('admin_name', function($row){
                        return $row->first_name.' '.$row->last_name;
                    })
                    ->setRowClass(function ($row) {
                        return $row->type; //The row class is set based on the log type 
                    })
                    ->make(true);
}

To change this for eloquent,

Migration

        Schema::create('log_activities', function (Blueprint $table) {
            $table->id(); //Alias of $table->bigIncrements('id')
            $table->string('subject', 5000);
            $table->string('url', 5000);
            $table->string('method',20);
            $table->string('ip',20);
            $table->string('agent')->nullable();
            $table->unsignedBigInteger('admin_id');
            $table->enum('type', ['info', 'notice', 'warning', 'error', 'critical', 'emergency'])->default('info');
            $table->timestamps();
        });

	Schema::table('log_activities', function($table)
        {
            $table->foreign('admin_id')->references('id')->on('admins');
        });



           Schema::create('admins', function (Blueprint $table) {
                $table->bigIncrements();
                $table->string('first_name');
                $table->string('last_name');
                $table->string('email')->unique();
                $table->timestamp('email_verified_at')->nullable();
                $table->string('password');
                $table->rememberToken();
                $table->timestamps();
                $table->softDeletes();
            });

relationship


class LogActivity extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'subject', 'url', 'method', 'ip', 'agent', 'admin_id', 'type'
    ];


    public function admin()
    {
        return $this->belongsTo(Admin::class, 'admin_id', 'id');
    }

}

controller

         
	$query = LogActivity::select(['subject', 'type', 'created_at')->with('admin:id,first_name,last_name')->get();
            
            return Datatables::of($query)
                    ->addColumn('admin_name', function($row){
                        return $row->first_name.' '.$row->last_name;
                    })
                    ->setRowClass(function ($row) {
                        return $row->type; //The row class is set based on the log type 
                    })
                    ->make(true);

view

<script>
$(function() {

    $('#logs-table').DataTable({
        paging: true, // Allow data to be paged
        searching: true, // Search box and search function will be actived
        ordering: true,

        lengthMenu: [[1, 10, 25, 50, -1], [1, 10, 25, 50, "All"]],
        pageLength: 10,

        autoWidth: true,
        
        dom: 'Blfrtip', //DOM variable for each element of the datatable
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ],

        processing: true,
        serverSide: true,

        ajax: '{!! route('admin.log.index') !!}',

        columns: [
            { data: 'subject', name: 'subject' },
            { data: 'admin_name', name: 'admin_name' },
            { data: 'created_at', name: 'created_at', orderable: false, searchable: false },
        ],

    });

});

</script>

I am not getting any error. I just get data displayed in admin_name column

In the below result, the admin relation does not return anything...

#items: array:17 [
    0 => RF\RFCmsLogs\Models\LogActivity {#1392
      #fillable: array:7 [
        0 => "subject"
        1 => "url"
        2 => "method"
        3 => "ip"
        4 => "agent"
        5 => "admin_id"
        6 => "type"
      ]
      #with: array:1 [
        0 => "admin"
      ]
      #connection: "mysql"
      #table: "log_activities"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:3 [
        "subject" => "Permission Group "Logs" has been created."
        "type" => "info"
        "created_at" => "2020-06-15 22:36:14"
      ]
      #original: array:3 [
        "subject" => "Permission Group "Logs" has been created."
        "type" => "info"
        "created_at" => "2020-06-15 22:36:14"
      ]
      #changes: []
      #casts: []
      #classCastCache: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:1 [
        "admin" => null
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [
        0 => "*"
      ]
    }

Any idea?

Just tried this

$records = LogActivity::all();

foreach($records as $r){
    print $r->admin->first_name;

}

and it works, so my belongsTo relationship must be properly setup...

May
27
3 months ago
Activity icon

Started a new Conversation Breadcrumbs Question

Hi,

Looks like this breadcrumb popular package is not maintained any more https://github.com/davejamesmiller/laravel-breadcrumbs

Is there any decent alternative around you can suggest?

May
25
3 months ago
Activity icon

Started a new Conversation How To Access A Custom Module Variable

Hi,

I have a custom module with variable

class MyTestProvider extends ServiceProvider
{
	public protected $module_name = "my-test";

In this very same service provider, I have controllers. How can my controller access the $module_name variable??

I tried to add in my controller constructor

print \Test\MyTestProvider::module_name;

but that does not work. It is looking for a constant which my variable is not...

Not sure what to do...

May
21
3 months ago
Activity icon

Replied to Authentication Question - 302 Code

@bugsysha Thanks for that. On the back if this, I am getting a little confused with the middleware of my dashboard routes

Route::group(['middleware' => ['web', 'auth:admin'], 'as' => 'admin.', 'prefix' => '/admin', 'namespace' => 'RF\RFCmsDashboard\Http\Controllers'], function()

The above works, but if I remove the 'web' middleware, the login page does not forward me to the dashboard page and only reloads the login page. That's confusing me.

Should 'web' always be added in route middleware? I have read in posts (https://laracasts.com/discuss/channels/laravel/middleware-web) that the web middleware was added automatically.

Activity icon

Started a new Conversation Authentication Question - 302 Code

Hi,

I am having issues with my authentication system. I am using laravel 7 and Laravel/UI

I had the following routes:

Route::prefix('/admin/')->name('admin.')->namespace('Admin\Auth')->group(function(){

    Route::get('login', '[email protected]')->name('login');
    Route::post('login', '[email protected]')
    Route::post('logout', '[email protected]')->name('logout');

    Route::get('password/reset', '[email protected]')->name('password.request');
    Route::post('password/email', '[email protected]')->name('password.email');
    Route::get('password/reset/{token}', '[email protected]')->name('password.reset');
    Route::post('password/reset', '[email protected]')->name('password.update');

    Route::get('password/confirm', '[email protected]')->name('password.confirm');
    Route::post('password/confirm', '[email protected]');

    Route::get('email/verify', '[email protected]')->name('verification.notice');
    Route::get('email/verify/{id}/{hash}', '[email protected]')->name('verification.verify');
    Route::post('email/resend', '[email protected]')->name('verification.resend');

});

I have a dashboard module with

Route::group(['middleware' => ['web', 'auth:admin'], 'as' => 'admin.', 'prefix' => '/admin', 'namespace' => 'RF\RFCmsDashboard\Http\Controllers'], function()
{
    
    App::setLocale(Session::get('lang'));

    Route::redirect('/', '/admin/dashboard');
    
    Route::get('dashboard','[email protected]')->name('dashboard');
    
});

I can not figure what is gong on. When I submit the login form. I get redirected to my dashboard upon authentication but I can see in my browser inspector a 302 error related to the login page with POST. The type of the request is type/html. It is followed by the dashboard page with a code 200.

Request URL: http://127.0.0.1:8000/admin/login
Request Method: POST
Status Code: 302 Found
Remote Address: 127.0.0.1:8000

I can display the name of user which indicates the user must have logged in successfuly. I use this code to display the user name

{{ Auth::guard('admin')->user()->first_name }}
May
09
4 months ago
Activity icon

Replied to Customising A Module

Hi @denniseilander

Thanks for the input. Are you suggesting I create the extended model in the App itself? I suppose I could do that... And then maybe have a configuration file for my package with a variable pointing to the Admin model I need to use. That might just work... What about the model form validation? obviously the new property is not in the Admin Request file. Would I need to extend that as well? It suddenly feels the parts of the package could be everywhere in the main App.

Is it possible to extend a package with another package??

Activity icon

Started a new Conversation Customising A Module

Hi,

I am writing a CMS working with modules and I have issues with the following scenario. Let's assume I have 2 websites and therefore 2 installations of the CMS. I have a 'Admin/Permission' module that manages administrators and permissions. if a bug is found, I can fix it and apply it to both systems using composer. That's easily done. My concern is more when one the system needs a customisation. Let's say after 6 month of usage, one the sites needs extra properties for the admin model. Updating the model, views... would have to be done but would be reflected in both CMS which we certainly don't want. What would be the best approach to allow this kind of flexibility ?

I am thinking of duplicating the 'Admin/Permission' module and customising it. Remove the current module, add the new module. Run a migration/seeding and all might still be working as before. But now I have 2 'Admin/Permission' module to maintain. Not great...

Any idea? suggestions?

May
03
4 months ago
Activity icon

Started a new Conversation URL Not Working

Hi,

I have setup the following routes.

/* ----------------------- Admin Routes START -------------------------------- */

/**
 * Admin Auth Route(s)
 */
Route::prefix('/admin/')->name('admin.')->namespace('Admin\Auth')->group(function(){

    //Login Routes
    Route::get('/login','[email protected]')->name('login');
    Route::post('/login','[email protected]');
    Route::post('/logout','[email protected]')->name('logout');

    //Forgot Password Routes
    Route::get('/password/reset','[email protected]')->name('password.request');
    Route::post('/password/email','[email protected]')->name('password.email');

    //Reset Password Routes
    Route::get('/password/reset/{token}','[email protected]')->name('password.reset');
    Route::post('/password/reset','[email protected]')->name('password.update');

});




//Runs with auth middleware
Route::prefix('/admin')->middleware('auth:admin')->name('admin.')->namespace('Admin')->group(function(){
    
    App::setLocale(Session::get('lang'));

    Route::get('dashboard','[email protected]')->name('dashboard');

    Route::get('home', '[email protected]')->name('home');

    Route::get('logs','[email protected]', ['only' => ['index'] ])->name('logs.index');

    Route::get('errors-log','[email protected]', ['only' => ['index'] ])->name('errorslog.index');

});

/* ----------------------- Admin Routes END -------------------------------- */

if I go to /admin/, I keep getting: The requested resource /admin/ was not found on this server.

I added in my route

    Route::redirect('/', '/dashboard');
    Route::get('','[email protected]');

but that does not help.

Is it because there is nothing after the second forward slash. Do I need to add a 301 redirect in the .htaccess??

Any idea?