qteck

Member Since 2 Years Ago

Karlovy Vary

Experience Points 7,890
Experience Level 2

2,110 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 64
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

12 Sep
7 months ago

qteck left a reply on POST Method, AJAX And Routes

okay, I just found out what the problem was.

it was not taking the relative url correctly for some reason:

url: "{{ url('/knihy/platba/') }}",

That's how it works.

qteck left a reply on POST Method, AJAX And Routes

The token is okay. I just checked the output of the token variable and what is in the form input. They match.

error: function (e) {
    console.log(JSON.stringify(e));
}

when I get the actual error this way it returns: 'whoops. something went wrong.'

I can access it with Route::get('knihy/platba', 'Knihy\[email protected]');

but Route::post('knihy/platba', 'Knihy\[email protected]');

return the 'whoops. something went wrong.'

11 Sep
7 months ago

qteck started a new conversation POST Method, AJAX And Routes

Hello,

I cannot get my POST form running. When I use the method GET and the GET route, it works.

Route::post('knihy/platba', 'Knihy\[email protected]');

$.ajax({ url: "/knihy/platba/", method: "POST", dataType: 'json', data: { 'forename': "John", '_token': token },

                              success(s){console.log("success"+token);},
                              error(e){console.log("unsucess");}
                })

knihy/platba

function paypalPayment(Request $request) {
    //dd($request);

    $orders = new Orders($request->all());
    $orders->save();
    return json_encode(array('state' => 1));
    exit;
}

when using the get method it goes through and return the json response.

when I use the POST method laravel gives out: oups something went wrong. and the .log is empty.

thank you.

14 Jul
9 months ago

qteck left a reply on Errror 500 After Upload On Server

http://www.thefamousliterarygroup.co.uk/index.php

so I ran install and update now and it says: nothing to update or install.

http://www.thefamousliterarygroup.co.uk/setup.php php info

there are no logs being generated.

Where can I find the web server logs?

yes the server set up should be same apart from PHP version. I think that the new wamp has 7.3...

qteck started a new conversation Error 500

I installed laravel using SSH and composer.

I created a project using composer and everything downloaded itself.

I go into the public folder and it gives 500.

the version of php on the server is 7.2

i assigned the chmod 777 to storage and bootstrap

and it just doesnt work.

holy mother.

qteck started a new conversation Errror 500 After Upload On Server

Hello,

I have uploaded my project on server and it stopped working. Gives 500 instead.

I tried: reassign chmod a tried all possible commands in artisan regarding cache I generated a new key I checked the php version on my server which is 7.2

I cant find out what the problem is. It feels like I tried everything.

21 Aug
1 year ago

qteck started a new conversation How To Mirror Store Folder

Hey folks I need to access my store folder in public directory. How to do it in win 8.1?? Thank you. Peet

07 Aug
1 year ago

qteck started a new conversation Website Downloaded From Hosting Has Problem With Ciphers

Hello,

I have downloaded a website which is running fine on server but I cannot make it run on localhost.

The log return:

[2017-08-07 13:04:44] production.ERROR: exception 'RuntimeException' with message 'The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.' in C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43 Stack trace: #0 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(27): Illuminate\Encryption\Encrypter->__construct(NULL, 'AES-256-CBC') #1 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(746): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption{closure}(Object(Illuminate\Foundation\Application), Array) #2 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(644): Illuminate\Container\Container->build(Object(Closure), Array) #3 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(709): Illuminate\Container\Container->make('encrypter', Array) #4 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(864): Illuminate\Foundation\Application->make('Illuminate\Cont...') #5 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(819): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #6 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(790): Illuminate\Container\Container->getDependencies(Array, Array) #7 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(644): Illuminate\Container\Container->build('App\Http\Middle...', Array) #8 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(709): Illuminate\Container\Container->make('App\Http\Middle...', Array) #9 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(127): Illuminate\Foundation\Application->make('App\Http\Middle...') #10 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #11 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request)) #12 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Router.php(644): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #13 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Router.php(618): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #14 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Router.php(596): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #15 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(267): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #16 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request)) #17 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request)) #18 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(137): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #19 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #20 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request)) #21 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #22 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #23 C:\wamp64\www\kerouac\public\index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #24 {main} [2017-08-07 13:04:44] production.ERROR: exception 'RuntimeException' with message 'The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.' in C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43 Stack trace: #0 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(27): Illuminate\Encryption\Encrypter->__construct(NULL, 'AES-256-CBC') #1 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(746): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption{closure}(Object(Illuminate\Foundation\Application), Array) #2 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(644): Illuminate\Container\Container->build(Object(Closure), Array) #3 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(709): Illuminate\Container\Container->make('encrypter', Array) #4 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(864): Illuminate\Foundation\Application->make('Illuminate\Cont...') #5 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(819): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #6 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(790): Illuminate\Container\Container->getDependencies(Array, Array) #7 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Container\Container.php(644): Illuminate\Container\Container->build('App\Http\Middle...', Array) #8 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(709): Illuminate\Container\Container->make('App\Http\Middle...', Array) #9 C:\wamp64\www\kerouac\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(173): Illuminate\Foundation\Application->make('App\Http\Middle...') #10 C:\wamp64\www\kerouac\public\index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response)) #11 {main}

I have run : php artisan key:generate and config clear, but none seems to help it, it just return all the time this message.

Thank you.

21 Jan
2 years ago

qteck started a new conversation Select A Value From A Colection

hello,

i am not sure how to get the value of ID from this record.

array:1 [▼ 0 => Gallery {#214 ▼ #table: "galleries" #connection: null #primaryKey: "id" #keyType: "int" #perPage: 15 +incrementing: true +timestamps: true #attributes: array:8 [▶] #original: array:8 [▼ "id" => 1 "title" => "Úvodní fotka 2013" "content_in_brief" => "Focení na úvodní fotku facebooku" "music" => "" "place" => "Stirling, Scotland" "author_id" => 1 "created_at" => "2016-10-13 21:32:09" "updated_at" => "2016-10-20 22:23:19" ] #relations: [] #hidden: [] #visible: [] #appends: [] #fillable: [] #guarded: array:1 [▶] #dates: [] #dateFormat: null #casts: [] #touches: [] #observables: [] #with: [] +exists: true +wasRecentlyCreated: false } ]

I have tried to get there using some of the collection methods like all, get and after ->id a property.

eventually I ended up writing something like gallery->where()->all()[0]->get('id') and so on.

any idea how to get it not using foreach? it is supposed to be anyway just one record.

Thank you.

12 Nov
2 years ago

qteck left a reply on How To Protect Images And Files

Take a look at this, I think I have seen a video about it on laracast.

https://laravel.com/docs/5.3/filesystem

qteck started a new conversation Getting Dates As String When Using Select

$articles = collect(DB::select('select *, a from (select *,scheduled as a from articles where scheduled is not null
union
select *,created_at as a from articles where scheduled is null) as sorted_articles where a <= now() order by a          DESC'));

qteck started a new conversation Associated Name - Query Builder

Hello, I wanna put this query through mysql database. ('select id, a from (select *,scheduled as a from articles where scheduled is not null union select *,created_at as a from articles where scheduled is null) as sorted_articles where a <= now() order by a DESC') I wrote this: $articles = DB::table('sorted_articles') ->select(DB::raw('(select *,scheduled as a from articles where scheduled is not null union select *,created_at as a from articles where scheduled is null) as sorted_articles')) ->where('a','<=','now()') ->orderBy('a', 'desc') ->get()->toSql();

but it tells me that the table: sorted_articles doesn't exist.

How can I put that query through?

07 Nov
2 years ago

qteck left a reply on Changed Double Type Number 222.0001 To 222

willvincent: don't you think he hit the point?

qteck left a reply on Changed Double Type Number 222.0001 To 222

thankx, but i am not sure how it should actually look like. I have a table notes> id - parent_id - content - label - article_id - user_id - created_at - updated_at

to get notes I select an article to edit. I set up a relationship hasMany (notes) and after foreach it.

if I put something in between than I need to set up another table, right? for example related_notes.

than to select an article, create new instance of notes put an id through DI and in the model table Notes set up relationship hasMany(related_notes)?

qteck left a reply on Changed Double Type Number 222.0001 To 222

i wanna create a menu, story line menu for an article section, where you can push some new idea in between existing ones.

to make it of double numbers seems to be the best idea to me.

id 1 2 3 4

and if I want to put something between 1 and 2 then I send id of value: 1.001 1 1.001 2

Any better ideas are very welcome.

Thank you.

qteck started a new conversation Changed Double Type Number 222.0001 To 222

HI,

  #attributes: array:7 [▼
    "id" => 258.0001
    "content" => "sadsadsadsad"
    "label" => ""
    "article_id" => 1
    "user_id" => 1
    "created_at" => "2016-11-07 15:19:28"
    "updated_at" => "2016-11-07 15:19:28"
  ]

I am getting the id classic way in view {{ $note->id }} In this variable I have got rounded value 258 even though I am not editing it in any sort of way.

THX

04 Nov
2 years ago

qteck left a reply on Jquery Post Request

It was cause by those routes.

Route::post('admin/dealer/add-article/note/{id}', 'Admin\[email protected]'); Route::post('admin/dealer/add-article/note/delete', 'Admin\[email protected]');

03 Nov
2 years ago

qteck left a reply on Jquery Post Request

I am getting this object. But how is it possible? Shouldn't I get the content what the PHP script is returning? for example an error of script?

qteck left a reply on Jquery Post Request

I get : Object {id: Object, _token: "rIDBJ3mAEnwaSE4duK3pSUBbG3mCtkXUpxJZQoWj"}

qteck started a new conversation Jquery Post Request

Hello,

I would like to delete a note from DB using AJAX. I want it to work with JS switched off. The version for non JS works fine but I am having a problem with the AJAX part. I am sending CSFR token and some data. I can see it return 200 but the note doesn't get deleted.

The ajax looks like this: $(".delete").click(function(){ var id = $(this).data(); var token = '{{ csrf_token() }}';

        $.ajax({
          type: 'POST',
          url: "{{ url('/') }}/admin/dealer/add-article/note/delete",
          data: {'id': id, '_token': token}, 
          dataType: 'json',
          success: function (response) {
            console.dir(response);
          },
          error: function (response) {
            console.log('errorPost');
          },
        });
        $(this).parent().remove();
        return false;
      });

The success part returns object: Object_token: "rIDBJ3mAEnwaSE4duK3pSUBbG3mCtkXUpxJZQoWj"id: Object id: "16"proto: Object__proto__: Object

but it is weird because I am not returning anything at the page except from dd() in controller.

     public function deleteNote(Request $request, $id = null)
       {
          dd($request);
          exit;
           if ($id == null) {
                $id = $request->id;
             }
            $note = Note::where('id', $id)->where('user_id', Auth::user()->id)->delete();
         return back()->with('successNote', 'You deleted a note.');
    }

https://github.com/qteck/LiteraryGroupKerouac/blob/dev/app/Http/Controllers/Admin/AddArticleController.php

02 Nov
2 years ago

qteck left a reply on Form Action, MethodNotAllowedHttpException

I have just started diving in Laravel.

I don't consider the same get/post routes a good solution either.

I have checked my config and there is written that the app is in production mode. So I didn't expect any debugger running.

Thanks for a lesson.

01 Nov
2 years ago

qteck left a reply on Form Action, MethodNotAllowedHttpException

:D, what sort of questions are those?

I am looking for bugs in it and trying to fix it. All 'unIFed' inputs and exceptions. I am trying to make it errorless.

I don't like those pages which just pop up in the middle of doing something.

I consider this post route to be something like an article which doesn't exist but you get on the page and it want tell you anything normal except from

bla bla bla.

Another thing is. Those places are not supposed to be available to an ordinary users.

I don't want to expose any directories and so on.

qteck left a reply on Form Action, MethodNotAllowedHttpException

because it gives this details:

Whoops, looks like something went wrong.

1/1 MethodNotAllowedHttpException in RouteCollection.php line 218: in RouteCollection.php line 218 at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 205 at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 158 at RouteCollection->match(object(Request)) in Router.php line 755 at Router->findRoute(object(Request)) in Router.php line 610 at Router->dispatchToRoute(object(Request)) in Router.php line 596 at Router->dispatch(object(Request)) in Kernel.php line 267 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Kernel.php line 149 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 at Kernel->handle(object(Request)) in index.php line 54

it runs like that in production environment.

qteck started a new conversation Form Action, MethodNotAllowedHttpException

Hi,

I have got a simple form to insert a note to an article. It works fine but when I take the content of action='' which is: http://localhost/kerouac/public/admin/dealer/add-article/note/1 and paste it into the url bar I get MethodNotAllowedHttpException in RouteCollection.php line 218:

It happens because the route I have got in web.php expects post but gets get. Route::post('admin/dealer/add-article/note/{id}', 'Admin\[email protected]');

one route more would sort it out but it feels quite bad and it is getting messy and confusing also. Route::get('admin/dealer/add-article/note/{id}', 'Admin\[email protected]');

Is there any nicer way? Thank you.

31 Oct
2 years ago

qteck started a new conversation Undefined Property

Hello,

I have created adding article and update of it. It goes through the same view which looks like this:

              <input type="text" name="title" value="{{ old('title') != null ? old('title') : @$articleToEdit->title }}" id="articleTitle" class="form-control btn-margin" placeholder="add title.." >
              
              <textarea name="contentInBrief" id="summernote" placeholder="add a brief content" >{{ old('contentInBrief') != null ? old('contentInBrief') : @$articleToEdit->content_in_brief }}</textarea>
              <div class="row text-muted small padding-letters-words">
                  <div class="col-md-6">(article has to contain 100 characters at least)</div>
                  <div class="col-md-6 text-right">Approximately: <span id="chars">0</span> letters, <span id="words">0</span> words </div>
              </div>
              
              <textarea name="content" id="summernote1" placeholder="and carry on with article...">{{ old('content') != null ? old('content') : @$articleToEdit->content }}</textarea>
              <div class="row text-muted small padding-letters-words">
                  <div class="col-md-6">(article has to contain 1000 characters at least)</div>
                  <div class="col-md-6 text-right">Approximately: <span id="chars1">0</span> letters, <span id="words1">0</span> words </div>
              </div>

The problem is obvious I guess: {{ old('contentInBrief') != null ? old('contentInBrief') : @$articleToEdit->content_in_brief }}

It return undefined property because of this:$articleToEdit->content_in_brief

As I am viewing existing data when sending ID in url I need the variable in there. On the other hand when I am creating an article the variable is empty. The best solution how to suprese the notice seems to be @ but I know it is considered to be a bad practise. Does anybody has better solution?

To be even cooler> {{ (old('contentInBrief') != null ? old('contentInBrief') : (!empty($articleToEdit->content_in_brief) ? $articleToEdit->content_in_brief: '')) }}

dont shag me.

]

Thank you.

qteck left a reply on Layout Variables

the problem was that I called it outside the middleware.

public $user;

    public function __construct()
    {
        $this->middleware('auth');
        
            $this->middleware(function ($request, $next) {
                        $this->user = Auth::user();
                        
                        view()->share('user', $this->user);

                    return $next($request);
            });
    }

this works. Thank you.

qteck left a reply on Layout Variables

at the moment it looks like this:

class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct()
    {
        $this->middleware('auth');
        
            $this->middleware(function ($request, $next) {
                        $this->user= Auth::user()->name; // dont forget to add the property
                    
                    return $next($request);
            });
            dd($this->user); // return errror
   //return view()->share('user', $this->user);
        

    }

and i am getting > ErrorException in Controller.php line 27: Undefined property: App\Http\Controllers\Admin\HomeController::$user

when I dd() in the middleware closure I ll get the value but not outside of it.

Thank you.

qteck left a reply on Layout Variables

Does anyone have an idea why $this->user = Auth::user(); is empty in the parent Controller?

namespace App\Http\Controllers\Admin;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;

    class Controller extends BaseController
    {
        use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

       public function __construct()
        {
            $this->middleware('auth');
                        $user = Auth::user();
            dd($user);

        }

user gives me null

Thank you

qteck left a reply on Layout Variables

than it was a bad example. it is not the only thing i wanna get in the views. it can be whatever, the date of last log in, or menu generated based on db common for all the view and so on.

I have just found something so we ll se how i ll get on :]

https://laravel.com/docs/5.3/views#sharing-data-with-all-views

but thanks anyway.

qteck started a new conversation Layout Variables

Hello,

I have got admin layout.blade and some sub views.

When I log into the admin section I want to show content of the same variables as: last login, name, .. on the top of the page.

Where should I define those variables? I dont want to write it in every single controller I call.

I have created App\Http\Controllers\Admin\Controller.php and started with this:

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

   public function __construct()
    {
        $this->middleware('auth');

        $this->user = Auth::user();
    }

     public function logout() 
    {
        Auth::logout();
        
        return redirect('admin/dealer');
        
    }
}

i guess the logout and the middleware methods are not that bad solution but what I don"t like is: $this->user = Auth::user();

Now if I start writing any new Controller I have to remember to pass $this->user to the view.

so is there any way I can pass this variable in Controller.php to avoid passing it in the child controllers?

Thank you.

28 Oct
2 years ago

qteck left a reply on Controller

after I rewrote it I dont get the content of {{ old('contentInBrief') }}

Why?

Thank you.

qteck left a reply on Controller

As martinbean mentioned above:"I’d also move the validation to a form request class." https://laravel.com/docs/5.3/validation#form-request-validation

I would like to do that but the request class demands to type hint its name into the controller but there has been already one: function create(Request $request) {

How should I do this?

Thank you.

27 Oct
2 years ago

qteck left a reply on Controller

but that is beautiful,

thank you very much.

qteck left a reply on Controller

what if someone send you a request which is not going to be $request->publish nor $request->draft?

than you ll get an empty row but it could sort out just a simple else {} but anyway I think this a a good example for what I am actually not sure about.

What if I need to write a function outside the controller file, e.g upload for a gallery. where should I write it?

qteck started a new conversation Controller

Hello,

I have just built a controller to take care of showing and creating an article. There are some code repetitions and I would like to write it in little bit different way.

I want to keep the controller as clean as possible but at the moment the method create() is getting quite messy and it is just the basic in it.

I could write a function just in the controller which will take care of inserting the article and call it later. isn't it a bad practice?

Here's the controller> https://github.com/qteck/LiteraryGroupKerouac/blob/dev/app/Http/Controllers/Clanky/ClankyController.php

what is the best way to check the true or false of the insert call> $articleTest = Article::insert(); if ($articleTest)

Thank you.

24 Oct
2 years ago

qteck started a new conversation Routes::auth

Hi,

I have just changed the structure of auth a little.

I am calling routes::auth in web.php

I would like to change the method Auth.

public function auth()
{
    // Authentication Routes...
    $this->get('login', 'Auth\[email protected]')->name('login');
    $this->post('login', 'Auth\[email protected]');
    $this->post('logout', 'Auth\[email protected]')->name('logout');

    // Registration Routes...
    $this->get('register', 'Auth\[email protected]');
    $this->post('register', 'Auth\[email protected]');

    // Password Reset Routes...
    $this->get('password/reset', 'Auth\[email protected]');
    $this->post('password/email', 'Auth\[email protected]');
    $this->get('password/reset/{token}', 'Auth\[email protected]');
    $this->post('password/reset', 'Auth\[email protected]');
}

I would like to do it in the way I won't affect the original src. I am not sure how to write that and where.

Normally I would probably just extend a class and tweak it a little but at the moment I am a confused because the Router::Auth is called in web.php.

Should i just write it in web.php

use ....\router

class blabla extends Router { function Auth(){} }

blabla::Auth();

Now I have noticed that it is Auth:routes() but the class is called Routes and the method is Auth, so it should be Routes::Auth()? right?

23 Oct
2 years ago

qteck started a new conversation Auth, Changed Structure

Hello,

I have just tried to change structure of it.

Unfortunately I am getting an error back.

       InvalidArgumentException in FileViewFinder.php line 137:
       View [auth.login] not found.

I have changed the views location and the HomeController. That's pretty much it. I have changed the return of the view in Home controller and namespace https://github.com/qteck/LiteraryGroupKerouac/blob/dev/app/Http/Controllers/Admin/HomeController.php

and changed some other bits. but I didn't get really far .

There few more info which is under the error> in FileViewFinder.php line 137 at FileViewFinder->findInPaths('auth.login', array('E:\wamp\www\kerouac\resources\views')) in FileViewFinder.php line 79 at FileViewFinder->find('auth.login') in Factory.php line 174 at Factory->make('auth.login', array(), array()) in helpers.php line 855 at view('auth.login') in AuthenticatesUsers.php line 20

It is obviously passing a wrong view address but I cant find it.

Thank you.

20 Oct
2 years ago
19 Oct
2 years ago

qteck left a reply on How To Access Packages In App\vendor In Public Directory

but, isn't it considered to be a mistake?

I am learning how to use Laravel and if I download a package I want to have it put together the right way.

Thank you.

qteck started a new conversation How To Access Packages In App\vendor In Public Directory

Hello, I wanna access my photoswipe package in app\vendor but I have got access just to app\ public directory on webserver.

"You'd use something like GulpJS to compile the vendor files/assets into your production ready files. You can reference vendor files and for example if you use npm, you can reference it like so ../node_modules/someLibrary/library.min.js" (bashy)

That is probably the answer to my question but I have no previous experience with node, neither gulp.

I have been watching youtube tutorials but I am still not sure. What to do with it. To install gulp I needed to install node. Node npm is the same sort of things as composer which I have already had in my project.

It seems to be wrong to combine node npm and composer. Eventually there is going to be composer.json, package,json, and gulpfile,js. Which is to be called first?

And now to make it even more confusing lets add Elixir and Laravel package doc. https://laravel.com/docs/5.3/packages#public-assets

Bashi said to compile the file and that is very good idea to make it small. and I want to do it. To do it do I need gulp?

If I keep composer and npm how can I make sure the package manager will update the assets in public directory.

uff.

If you got down here thank you for reading all that.

18 Oct
2 years ago

qteck started a new conversation How To Approach Js Library In Vendor

Hello,

I have just downloaded lightbox with composer to file called Vendor.

I would like to put the path to it but I dont think I actually can do it.

folder with index is> app/public/index.php so if i set the root up: public/ I am not going to have access to-:app/vendor/photoswipe.min.js

so if this is in index.php the address would look like this

it won't load.

What to do with it? if i move the lightbox to public/js/ than I don't need to use composer right? but that will mess the project up.

Thank you.

qteck started a new conversation First In Template

Hello,

is there any better way how to do this> $gallery->photos->first()->title

Thank you.

13 Oct
2 years ago

qteck started a new conversation Relationship Between Month And Month_id

Hello,

I can't sucesfully define a relationship between month_id.articles and id.month

I have written this into Article Model:

function month () {
return $this->belongsTo('\App\Month');
}

I am trying to call it: Article::all()->month but it is empty.

this one works: $currentMonth = Month::all()->where('id','=', $mesic); but it is not what i want. I would like to pass it as a relationship.

the article controller looks like this:

    <?php

    namespace App\Http\Controllers\Clanky;

    use Illuminate\Http\Request;

    use App\Http\Requests;
    use App\Http\Controllers\Controller;

    use App\Article;
    use App\Month;

    class ClankyController extends Controller
    {
        function index($mesic = NULL) {
        $articles = Article::all();

                dd($articles);

            if(!empty($mesic)) {
                $articles = $articles->where('month_id','=', $mesic);
                             // $currentMonth = Month::all()->where('id','=', $mesic);

                            //dd($currentMonth);

                if (empty($articles->toArray())) {
                    \App::abort(404);
                }
            }

            $months = Month::withCount('articles')->get();  // fetch all the months

            return view('clanky.clanky', compact('articles', 'months','currentMonth'));
        }

        function show(Article $article) {
        
            return view('clanky.clanek', compact('article'));
        }
    }

Thank you.

12 Oct
2 years ago

qteck started a new conversation Hw To Format Datetime - Protected $dateFormat = 'U';

Hi,

i would like to format date in my view:

<div class="row text-muted text-right version">
Verze {{  $manifest->version }} uvolněna {{ date('d.m.Y', strtotime($manifest->created_at))  }} 
</div>

I have defined this variable : protected $dateFormat = 'U'; in model. It returns an error :

"ErrorException in Carbon.php line 425: Trailing data"

Where do I do the mistake :-) ???? Thank you

qteck left a reply on Abort 404

oh, yeah.

I actually cannot test it just like that because $article is full of objects.

    if (empty($articles->toArray())) 

this one works fine.

Is there any better way how to test it?

qteck left a reply on Laravel 5 App::abort(404)

oh, yeah.

I actually cannot test it just like that because $article is full of objects.

    if (empty($articles->toArray())) 

this one works fine.

Is there any better way how to test it?

qteck started a new conversation Abort 404

Hi,

  1. why does \App::abort(404); function trigger itself when $articles->title has values in it? thx function index($mesic) { $articles = Article::all();

            if(!empty($mesic)) {
                $articles = $articles->where('month_id','=', $mesic);
                if (empty($articles->title)) {
                    \App::abort(404);
                }
            }
    
            $months = Month::withCount('articles')->get();  // fetch all the months
    
            return view('clanky.clanky', compact('articles', 'months'));
        }
    

qteck started a new conversation Sub Foreach In View

I am trying to build a table of months> January, February.... I want to have number of articles in brackets next to the particular month. January(2), February(∞) ....

I have got table Article and Months. Article contains Month_id which relates to Months AI ID.

Now I get the number of articles for particular months id in this way> count(Month::find(10)->articles).

        $months = Month::all(); //  I fetch 12 months 
         return view('clanky.clanky', compact('articles', 'months')); //  and give it to the view. 

             <ul class="article-months">
                 @foreach ($months as $month)
                     <li><a href="">{{ $month->month }} (      8       )</a></li>      //I need to get the value here. 
                 @endforeach
             </ul>

The problem is I get the ID of month in the foreach. I need to get this> count(Month::find(10)->articles instead of> ( 8 )

How can I get t to the view?

Thank you.

11 Oct
2 years ago

qteck left a reply on Eloquent Second Relationship

I am trying to build a table of months> January, February.... I want to have number of articles in brackets next to the particular month. January(2), February(∞) ....

I have got table Article and Months. Article contains Month_id which relates to Months AI ID.

Now I get the number of articles for particular months id in this way> count(Month::find(10)->articles).

        $months = Month::all(); //  I fetch 12 months 
         return view('clanky.clanky', compact('articles', 'months')); //  and give it to the view. 

             <ul class="article-months">
                 @foreach ($months as $month)
                     <li><a href="">{{ $month->month }} (      8       )</a></li>      //I need to get the value here. 
                 @endforeach
             </ul>

The problem is I get the ID of month in the foreach. I need to get this> count(Month::find(10)->articles instead of> ( 8 )

How can I get t to the view?

Thank you.