lilo

lilo

Member Since 2 Months Ago

Experience Points
2,490
Total
Experience

2,510 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
1
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 1
2,490 XP
Sep
25
2 days ago
Activity icon

Replied to How To Fade In A Div On My Website In 2 Seconds

@automica Thank you so much! Also there is a problem, if I don't wait for the loader and scroll down I can see the page. How can I prevent this? Even if I don't wait for the loader and scroll down, I don't want to see the site.

Sep
24
3 days ago
Activity icon

Replied to How To Fade In A Div On My Website In 2 Seconds

@automica Thanks for your detailed answer! I am curious about something,I made like this:

<script>
        $(document).ready(function() {

            // Hide the div
            $("#loader").hide();

            // Show the div in 5s
            $("#content").delay(5000).fadeIn(500);

        });
    </script>

But the loader doesn't display 5 secs. It suddenly show up and then the page is displaying.

My css is like this:

.load-full-screen { height: 100%; width: 100%; } #loader { position: relative; background: #f7f7f7; } #loader div { position: absolute; top: 50%; left: 45%; transform: translate(-50%,-45%); margin-top: 0 !important; } #loader span { text-align: center; }

Why do you think it is not delaying?

Activity icon

Started a new Conversation How To Fade In A Div On My Website In 2 Seconds

Hi,

In my index page, I want to hide my loader after 2 seconds.

Here is my loader:

<body class="load-full-screen scroll-assist">

    <!-- BEGIN: PRELOADER -->
    <div id="loader" class="load-full-screen">
        <div class="loading-animation">
            <span><i class="fa fa-plane"></i></span>
            <span><i class="fa fa-bed"></i></span>
            <span><i class="fa fa-ship"></i></span>
            <span><i class="fa fa-suitcase"></i></span>
        </div>
    </div>
    <!-- END: PRELOADER -->
<div class="nav-container">
	----content---
</div>

</body>

How to write this script and make loader div display none and nav container display block?

Sep
23
4 days ago
Activity icon

Started a new Conversation [Intervention] Unable To PreventDefault Inside Passive Event Listener Due To Target Being Treated As Passive. See <URL>

Hello,

I added an animation between pages while they are loading. It works but at the console I get this error:

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See

Here is my transition.css:

body{
animation: transitionIn 0.75s;

}

@keyframes transitionIn { from{ opacity: 0; background-image: url("/img/Preloader_11.gif"); } to { opacity: 1; background-image: url("/img/Preloader_11.gif"); } }

And I add this to the head of my page:

        <link rel="stylesheet" href="css/transition.css">

PS: So sorry I couldn't make the code looking good

Activity icon

Started a new Conversation How To Stop Animation While Page Is Loading

Hi,

I wanted to display an animation until the page loads completely but the icon doesn't stop and the page doesn't load successfuly. How can I fix this?

Here is my index page:

<head>
    ....
</head>
<style>
    .no-js #loader { display: none;  }
    .js #loader { display: block; position: absolute; left: 100px; top: 0; }
    .se-pre-con {
        position: fixed;
        left: 0px;
        top: 0px;
        width: 100%;
        height: 100%;
        z-index: 9999;
        background: url(https://smallenvelop.com/wp-content/uploads/2014/08/Preloader_11.gif) center no-repeat #fff;
    }
</style>
<script>
    $(window).on(‘load’, function() {
        // Animate loader off screen
        $(“.se-pre-con”).fadeOut(“slow”);
    });
</script>
<body class="scroll-assist">    
 <div class="se-pre-con">
   ..........
Sep
22
5 days ago
Activity icon

Started a new Conversation How To Access Data Through The Pivot Table

Hello, I have a many to many relationship and naturally a pivot table.

Here is my Project model:

public function dev_names()
{
    return $this->belongsToMany(Developer::class, 'developer_projeler','developer_id','projeler_id');
}

Here is my Project controller:

$project = Projeler::find(1);

    foreach ($project->dev_name as $dev_name) {
        $dev_name->pivot->developer_id;
        dd($dev_name);
    }

How can I access to the projects who has developers inside?

With the code above in controller I get this error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database.developer_projeler, CONSTRAINT projeler_id_fk_2211026 FOREIGN KEY (projeler_id) REFERENCES projelers (id) ON DELETE CASCADE) (SQL: insert into developer_projeler (developer_id, projeler_id) values (39, 8))

Activity icon

Replied to Old Data Recreating Every Time A New Data Is Entered In Model

Thanks for the link I used updateOrCreate() and it worked

Activity icon

Started a new Conversation Old Data Recreating Every Time A New Data Is Entered In Model

Hi,

I have an Bill model and an Income model in my panel.

In the Bill model, I enter a bill for a selected project. I have two different fields which are "is_paid" and "remaining". If it is paid, I mark yes "is_paid" field and enter the remaining money in "remaining" field.

When I click save, the bill is saving and a new entry is creating in Income model which has the same project id as the bill.

Also in Project model, I update the remaining money by adding the incomes for same project.

My problem is when I enter a bill for any project, all the Incomes are recreating.

Here is my BillContoller:

$bills = Bill::get();
    foreach ($bills as $bill){
        if ($bill->is_paid == 'yes') {
            $project = Projects::where('id', $bill->project_name_id)->get();
            foreach ($project as $prj){
                $income = Income::create(['project_name_id' => $bill->project_name_id, 'income_amount'=>$prj->remaining_money - $bill->remaining]);
                $prj->remaining_money = $prj->bill_amount - $income->income_amount;
                $prj->save(); 
            }
        }
        else {

        }
    }

How can I fix this?

Sep
21
6 days ago
Activity icon

Replied to Update The Data That Has Many To Many Relationship

Thanks for the link! Actually what I want to do is in Projects page the user will choose a developer or more, then the user will enter the developer expence on the same page. Whenever the user clicks the developer page, the debt must be updates equal to the dev expense

Activity icon

Replied to Update The Data That Has Many To Many Relationship

Oh okey, here is developer table:

public function up()
{
    Schema::create('developers', function (Blueprint $table) {
        $table->increments('id');
        $table->string('dev_name')->nullable();
        $table->string('dev_mail')->nullable();
        $table->string('iban_no')->nullable();
        $table->longText('not')->nullable();
        $table->integer('dev_telefon')->nullable();
        $table->decimal('total_odenmis', 15, 2)->nullable();
        $table->decimal('debt', 15, 2)->nullable();
        $table->timestamps();
        $table->softDeletes();
    });
}

Here is Projects table:

public function up()
{
    Schema::create('projelers', function (Blueprint $table) {
        $table->increments('id');
        $table->string('project_name')->nullable();
        $table->date('baslangic_tarihi')->nullable();
        $table->date('planlanan_bitis_tarihi')->nullable();
        $table->date('gercek_bitis_tarihi')->nullable();
        $table->decimal('bedeli', 15, 2)->nullable();
        $table->decimal('fatura_tutari', 15, 2)->nullable();
        $table->longText('odeme_plani')->nullable();
        $table->longText('not')->nullable();
        $table->string('masraf')->nullable();
        $table->string('fatura_isteme')->nullable();
        $table->decimal('kalan_tutar', 15, 2)->nullable();
        $table->decimal('dev_expense', 15, 2)->nullable();
        $table->timestamps();
        $table->softDeletes();
    });
}

Here is Developer+Projects pivot table:

public function up()
{
    Schema::create('developer_projeler', function (Blueprint $table) {
        $table->unsignedInteger('projeler_id');
        $table->foreign('projeler_id', 'projeler_id_fk_2211026')->references('id')->on('projelers')->onDelete('cascade');
        $table->unsignedInteger('developer_id');
        $table->foreign('developer_id', 'developer_id_fk_2211026')->references('id')->on('developers')->onDelete('cascade');
    });
}
Activity icon

Replied to Update The Data That Has Many To Many Relationship

If you excuse me, I don't fully understand what you mean

Activity icon

Replied to Update The Data That Has Many To Many Relationship

Can't I access those fields using the developer_project pivot table?

Activity icon

Replied to Update The Data That Has Many To Many Relationship

Nope, I downloaded the code from quick admin panel after designed it but now when I look at fillable array in the Project model, the dev_name doesn't exist in it. Should I write it? and then how can I retrieve the datas of the selected developer?

Activity icon

Replied to Update The Data That Has Many To Many Relationship

Anybody?

In my Projects model, the relationship is provided with this function:

public function dev_names()
{
    return $this->belongsToMany(Developer::class);
}

Here what I tried in my Projects controller:

$project = Projects::with('dev_names')->get();
   	$project->dev_names()->update(['debt' => $proje->dev_expense]);

But it doesn't update the data in the developer table

Activity icon

Started a new Conversation Update The Data That Has Many To Many Relationship

Hi,

I have 2 models which are Developers and Projects. A developer can have many projects and a project can have many developers. As there is many-to-many relationship, there is a table named developer_project in which there is project_id and developer_id. In Projects table, I have a column named "dev_expense". In Developers table, I have a column named "debt".

For the chosen developer, I want to save the dev_expense column in the Projects table equla to the debt column in the Developers table.

How can I do this?

Activity icon

Replied to How To Update Data Of Specific User With One To Many Relationship

Sorry I thought that there was entry for the first project's expense but there wasn't so that's why the dd returns null. The main problem is that this code doesn't update the data in Developer model. Also, about my second question I wanted to retrieve the data of the selected developers here: "$project = Projects::first()" not with dd();

Activity icon

Replied to How To Update Data Of Specific User With One To Many Relationship

Also here: "$project = Projects::first();", instead of retrieving the first data, how can I retrieve the data of the selected developers?

Activity icon

Replied to How To Update Data Of Specific User With One To Many Relationship

Sorry for my confused narration. But you totally get it! "So, set debt column in developers table equal to dev_expense value from projects table" this is what I want to do. Also, I tried your response but didn't work. Then I dump and die like this:

$project = Projects::first();
    dd($project->dev_expense);
    $project->developers()->update(['debt' => $project->dev_expense]);

But it gives null.

Activity icon

Replied to How To Update Data Of Specific User With One To Many Relationship

Hi, I have a developers and projects table. In projects, I can choose dev_name. So there is belongToMany relationship between them. But in database, there isn't dev_name column in Projecs table instead there is another table called "developer_projects" and in this table there is only two columns: these are project_id and dev_id. What I want to do is accessing the developer that I choose in Projects page and update its data in Developer page.

Activity icon

Replied to How To Update Data Of Specific User With One To Many Relationship

Thanks but not working also doesn't give any error

Activity icon

Started a new Conversation How To Update Data Of Specific User With One To Many Relationship

Hi,

In my code, what i want to do is update the data of the entered user.

I have a column named "dev_name" and another column named "dev_expense" in my Projects table.

In another table called Developer, I want to update for the entered "dev_name" the column named "debt" which is equal to "dev_expense" from Projects table.

There is 1-to-many relationship between projects and developer. This means one project can have 1 or more developers.

As it is set as 1-to-many, the panel doesn't has a related column as like "dev_name_id" in Projects table, so I don't know how to access the selected dev_name.

Here is what I tried in my controller but it doesn't work:

$project = Projects::with('dev_name')->get(); //I don't have dev_name column in my Projects table
    $developer = Developer::whereIn('id', $project->pluck('dev_name_id'))->get();	//I don't have dev_name_id column in my Projects table either
    $grouped = $project->groupBy('dev_name_id');
    $sums = $grouped->map->sum(function($projects) {
        return $projects->dev_expense;
    });

    foreach ($developer as $dev) {
        $dev->debt = $sums[$dev->id];
        $dev->save();
    }

In my Projects model, I have this:

public function dev_names()
{
    return $this->belongsToMany(Developer::class);
}

How can I fix this? Thanks in advance.

Sep
15
1 week ago
Activity icon

Started a new Conversation How To Make The First One Active In Side Navigation Menu?

Hi,

I want to make only the first entry active. How can I make it?

Here is my blade:

<div class="container clearfix topmargin bottommargin">
            <div id="side-navigation">
                @foreach($technology as $tech)

                    <div class="col_one_fourth nobottommargin">
                        <ul class="sidenav">
                            <li class="ui-tabs-active">
                                <a href="#{{ $tech->id }}">
                                    <i class="{{ $tech->icon }}"></i>
                                        {{ $tech->title }}
                                    <i class="icon-chevron-right"></i>
                                </a>
                            </li>
                        </ul>
                    </div>

                    <div class="col_three_fourth col_last nobottommargin">
                        <div id="{{ $tech->id }}">
                            <div class="heading-block">
                                <h3 style="text-transform: none">{{ $tech->title }}</h3>
                               
                            </div>
                            
                            @if($tech->title)
                                <img class="alignleft img-responsive" src="{{ asset($tech->photo->url) }}" >
                            @endif
                            <p>{!! $tech->text !!} </p>
                        </div>
                    </div>

                @endforeach

            </div>
        </div>
Activity icon

Replied to Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist File Does Not Exist

Thank you for your reply @bobbybouwmann. I didn't quite understand what you said but I definetely don't expect any image in here. I only wanted to get icon name as text and then display it on my website. Why I should use asset in a text field?

Activity icon

Started a new Conversation Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist File Does Not Exist

Hi,

I have a panel which I constructt using quick admin panel. In this panel, there is a crud named "FeaturedBox" and in this crud I have a field named "icon". But this icon is not photo type, it's text. Nevertheless I get this error (I wrote "icon-object-group1" on text area in panel ):

Spatie\MediaLibrary\Exceptions\FileCannotBeAdded\FileDoesNotExist File C:\Users\....\storage\tmp/uploads/icon-object-group1 does not exist

The controller of the featuredBox crud is given below:

public function index(Request $request)
{
    abort_if(Gate::denies('featured_box_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    if ($request->ajax()) {
        $query = FeaturedBox::query()->select(sprintf('%s.*', (new FeaturedBox)->table));
        $table = Datatables::of($query);

        $table->addColumn('placeholder', '&nbsp;');
        $table->addColumn('actions', '&nbsp;');

        $table->editColumn('actions', function ($row) {
            $viewGate      = 'featured_box_show';
            $editGate      = 'featured_box_edit';
            $deleteGate    = 'featured_box_delete';
            $crudRoutePart = 'featured-boxes';

            return view('partials.datatablesActions', compact(
                'viewGate',
                'editGate',
                'deleteGate',
                'crudRoutePart',
                'row'
            ));
        });

        $table->editColumn('id', function ($row) {
            return $row->id ? $row->id : "";
        });
        $table->editColumn('icon', function ($row) {
            if ($photo = $row->icon) {
                return sprintf(
                    '<a href="%s" target="_blank"><img src="%s" width="50px" height="50px"></a>',
                    $photo->url,
                    $photo->thumbnail
                );
            }

            return '';
        });
        $table->editColumn('title', function ($row) {
            return $row->title ? $row->title : "";
        });
        $table->editColumn('link', function ($row) {
            return $row->link ? $row->link : "";
        });

        $table->rawColumns(['actions', 'placeholder', 'icon']);

        return $table->make(true);
    }

    return view('admin.featuredBoxes.index');
}

public function create()
{
    abort_if(Gate::denies('featured_box_create'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    return view('admin.featuredBoxes.create');
}

public function store(StoreFeaturedBoxRequest $request)
{
    $featuredBox = FeaturedBox::create($request->all());

    if ($request->input('icon', false)) {
        $featuredBox->addMedia(storage_path('tmp/uploads/' . $request->input('icon')))->toMediaCollection('icon');
    }

    if ($media = $request->input('ck-media', false)) {
        Media::whereIn('id', $media)->update(['model_id' => $featuredBox->id]);
    }

    return redirect()->route('admin.featured-boxes.index');
}

public function edit(FeaturedBox $featuredBox)
{
    abort_if(Gate::denies('featured_box_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    return view('admin.featuredBoxes.edit', compact('featuredBox'));
}

public function update(UpdateFeaturedBoxRequest $request, FeaturedBox $featuredBox)
{
    $featuredBox->update($request->all());

    if ($request->input('icon', false)) {
        if (!$featuredBox->icon || $request->input('icon') !== $featuredBox->icon->file_name) {
            if ($featuredBox->icon) {
                $featuredBox->icon->delete();
            }

            $featuredBox->addMedia(storage_path('tmp/uploads/' . $request->input('icon')))->toMediaCollection('icon');
        }
    } elseif ($featuredBox->icon) {
        $featuredBox->icon->delete();
    }

    return redirect()->route('admin.featured-boxes.index');
}

public function show(FeaturedBox $featuredBox)
{
    abort_if(Gate::denies('featured_box_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    return view('admin.featuredBoxes.show', compact('featuredBox'));
}

public function destroy(FeaturedBox $featuredBox)
{
    abort_if(Gate::denies('featured_box_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $featuredBox->delete();

    return back();
}

public function massDestroy(MassDestroyFeaturedBoxRequest $request)
{
    FeaturedBox::whereIn('id', request('ids'))->delete();

    return response(null, Response::HTTP_NO_CONTENT);
}

public function storeCKEditorImages(Request $request)
{
    abort_if(Gate::denies('featured_box_create') && Gate::denies('featured_box_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $model         = new FeaturedBox();
    $model->id     = $request->input('crud_id', 0);
    $model->exists = true;
    $media         = $model->addMediaFromRequest('upload')->toMediaCollection('ck-media');

    return response()->json(['id' => $media->id, 'url' => $media->getUrl()], Response::HTTP_CREATED);
}

I'm stuck with it. How can I fix this?

Sep
14
1 week ago
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

Thank you very much! I thought I did the php artisan storage: link at the beginning of the project, but when I remade it everything started working fine!

Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

Thanks but still images are not displaying. The images are in storage file and I get this error too:

5f5f4843324a4_turkcell.jpg:1 GET http://127.0.0.1:8000/storage/8/5f5f4843324a4_trkcell.jpg 404 (Not Found)

When I look at the src of my image from inspector the path is same as http://127.0.0.1:8000/storage/8/5f5f4843324a4_trkcell.jpg

I upload my images from panel to database why there can be this problem?

Activity icon

Started a new Conversation Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

Hi,

I want to retrieve an image from database but I get this error on the console:

Failed to load resource: the server responded with a status of 404 (Not Found)

How can I fix it?

Here is my route:

Route::get('/', function () {
$reference=App\Reference::orderBy('created_at','DESC')->get();
return view('index',[ 'reference'=>$reference]);});

And here is my blade:

<div class="container clearfix">
            <div id="oc-clients" class="owl-carousel owl-carousel-full image-carousel carousel-widget" data-margin="30" data-loop="true" data-nav="false" data-autoplay="5000" data-pagi="false" data-items-xs="2" data-items-sm="3" data-items-md="4" data-items-lg="5" data-items-xl="6" style="padding: 20px 0;">

                @foreach($reference as $ref)
                    <div class="oc-item">
                        @if($ref->link)
                            <a href="{{ $ref->link }}" target="_blank">
                                @if($ref->logo->first())
                                    <img src="{{ $ref->logo->url }}">
                                @endif
                            </a>
                        @endif
                    </div>
                @endforeach
	</div>
</div>
Sep
11
2 weeks ago
Activity icon

Replied to Trying To Get Property 'url' Of Non-object

I made the panel using quick admin panel. In my Reference table there is two columns which are logo and link. The field type of the logo column is photo. And when I look at the db after doing migrations, there is a media table in which all the photo type images is stored. In previous projects, when I want to access the logo, I was able to access it using {{ $somevar->photo->url }} but when I do it in this projecti there is error.

Also, could this error have something to do with the logo's path? Because when I look at the panel and click on the photo that I upload I get 404 Error.

I hope I could explain and thanks for your help

Activity icon

Replied to Trying To Get Property 'url' Of Non-object

Ah yes.. So sorry but the problem continues. It gives " htmlspecialchars() expects parameter 1 to be string, object given "

Activity icon

Replied to Trying To Get Property 'url' Of Non-object

When I use like given below, it start to give the same error which is "Trying to get property 'url' of non-object"

@foreach($reference as $ref)
                    <div class="oc-item">
                        @if($ref->link)
                            <a href="{{ $ref->link }}" target="_blank">
                                <img src="{{ $ref->logo->url }}">
                            </a>
                        @endif
                    </div>
                @endforeach
Activity icon

Replied to Trying To Get Property 'url' Of Non-object

Still not working... I'm retrieving the data from db but also I upload the images into db through a panel. The last status of the code is given below:

My blade:

@foreach($reference as $ref)
                    <div class="oc-item">
                        @if($ref->link)
                            <a href="{{ $ref->link }}" target="_blank">
                                <img src="{{ env('APP_URL'). $ref->logo }}">
                            </a>
                        @endif
                    </div>
                @endforeach

My controller:

public function show($link)
{
    $reference =DB::table('references')->where('link',$link)->first();

    if($reference){
        abort(404);
    }
}

public function update(Request $request)
{
    $path = $request->file('logo');
    return $path;
}
Activity icon

Replied to Trying To Get Property 'url' Of Non-object

Yes they are just different columns in the same table

But with this code above, only the name of the image is displayed not the image itself.

Activity icon

Replied to Trying To Get Property 'url' Of Non-object

The error doesn't change unfortunately. Actually there is this crud named "Reference" and I have two columns in it which are logo and the link. I want to display them in index page as carousel items. When the user clicking on the logo, it must directed to the link of this logo. I made the carouel item and the links but can't retrieve the logos dynamically. I made the changes as you say in my controller and blade but nothing changed.

Activity icon

Started a new Conversation Trying To Get Property 'url' Of Non-object

Hi,

I want to display image which is in my storage field. I want to retrieve this from the database but I get this error:

ErrorException Trying to get property 'url' of non-object

Here is my blade:

<div class="container clearfix">
            <div id="oc-clients" class="owl-carousel owl-carousel-full image-carousel carousel-widget" data-margin="30" data-loop="true" data-nav="false" data-autoplay="5000" data-pagi="false" data-items-xs="2" data-items-sm="3" data-items-md="4" data-items-lg="5" data-items-xl="6" style="padding: 20px 0;">

                @foreach($reference as $ref)
                    <div class="oc-item">
                        <a href="{{ $ref->link }}" target="_blank">
                            <img src="{{ $ref->logo->url }}">
                        </a>
                    </div>
                @endforeach

            </div>
</div>

Also here is my controller:

public function show($link)
{
    $reference =DB::table('references')->where('link',$link)->first();

    if($reference){
        abort(404);
    }
    
}

And my route:

Route::get('/', function () {
$response= Http::get('https://....../Services/publicapi/getcasecount');
$data = $response->json();
$featuredbox=App\FeaturedBox::all();
$slider=App\Slider::all();
$reference=App\Reference::all();
return view('index',['data'=>$data, 'featuredbox'=>$featuredbox, 'slider'=>$slider, 'reference'=>$reference]);});

How can I access the image truely? Thanks in advance

Sep
08
2 weeks ago
Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

Hi, I'm using bootstrap's datepicker.

Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

Here is my blade:

@extends('layouts.admin')

@section('content')

{{ trans('global.create') }} {{ trans('cruds.excuse.title_singular') }}
<div class="card-body">
    <form method="POST" action="{{ route("admin.excuses.store") }}" enctype="multipart/form-data">
        @csrf
        <div class="form-group">
            <label for="user_id">{{ trans('cruds.excuse.fields.user') }}</label>
            <select class="form-control select2 {{ $errors->has('user') ? 'is-invalid' : '' }}" name="user_id" id="user_id">
                @foreach($users as $id => $user)
                    <option value="{{ $id }}" {{ old('user_id') == $id ? 'selected' : '' }}>{{ $user }}</option>
                @endforeach
            </select>
            @if($errors->has('user'))
                <div class="invalid-feedback">
                    {{ $errors->first('user') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.user_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="start_date">{{ trans('cruds.excuse.fields.start_date') }}</label>
            <input class="form-control date {{ $errors->has('start_date') ? 'is-invalid' : '' }}" type="text" name="start_date" id="start_date" value="{{ old('start_date') }}">
            @if($errors->has('start_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('start_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.start_date_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="end_date">{{ trans('cruds.excuse.fields.end_date') }}</label>
            <input class="form-control date {{ $errors->has('end_date') ? 'is-invalid' : '' }}" type="text" name="end_date" id="end_date" value="{{ old('end_date') }}">
            @if($errors->has('end_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('end_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.end_date_helper') }}</span>
        </div>
        <div class="form-group">
            <button class="btn btn-danger" type="submit">
                {{ trans('global.save') }}
            </button>
        </div>
    </form>
</div>

My script at the end of the blade:

<script>
$(document).ready(function() {
    $("#start_date").datepicker({
        numberOfMonths: 1,
        onSelect: function(selected) {
            $("#end_date").datepicker("option", "minDate", selected)
        }
    });
    $("#end_date").datepicker({
        numberOfMonths: 1,
        onSelect: function(selected) {
            $("#start_date").datepicker("option", "maxDate", selected)
        }
    });
});

@endsection

And my controller:

class ExcuseController extends Controller { public function index(Request $request) { abort_if(Gate::denies('excuse_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    if ($request->ajax()) {
        $query = Excuse::with(['user', 'created_by'])->select(sprintf('%s.*', (new Excuse)->table));
        $table = Datatables::of($query);

        $table->addColumn('placeholder', '&nbsp;');
        $table->addColumn('actions', '&nbsp;');

        $table->editColumn('actions', function ($row) {
            $viewGate      = 'excuse_show';
            $editGate      = 'excuse_edit';
            $deleteGate    = 'excuse_delete';
            $crudRoutePart = 'excuses';

            return view('partials.datatablesActions', compact(
                'viewGate',
                'editGate',
                'deleteGate',
                'crudRoutePart',
                'row'
            ));
        });

        $table->editColumn('id', function ($row) {
            return $row->id ? $row->id : "";
        });
        $table->addColumn('user_name', function ($row) {
            return $row->user ? $row->user->name : '';
        });

        $table->rawColumns(['actions', 'placeholder', 'user']);

        return $table->make(true);
    }

    $users = User::get();
    $users = User::get();

    return view('admin.excuses.index', compact('users', 'users'));
}

public function create()
{
    abort_if(Gate::denies('excuse_create'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $users = User::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');

    return view('admin.excuses.create', compact('users'));
}

public function store(StoreExcuseRequest $request)
{
    $excuse = Excuse::create($request->all());

    $request->validate([
        'end_date' => 'after:start_date'
    ]);

    $excuses = Excuse::with('user')->get();
    $users = User::whereIn('id', $excuses->pluck('user_id'))->get();
    $grouped = $excuses->groupBy('user_id');
    $sums = $grouped->map->sum(function($excuse) {
        $start = $excuse->start_date;
        $end =$excuse->end_date;
        return Carbon::parse($start)->diffInDays($end,false);
    });

    foreach ($users as $user) {
        $user->remaining_permit = $user->excuse_count - $sums[$user->id];
        $user->save();
    }

    return redirect()->route('admin.excuses.index');
}

public function edit(Excuse $excus)
{
    abort_if(Gate::denies('excuse_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $users = User::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');

    $excus->load('user', 'created_by');

    return view('admin.excuses.edit', compact('users', 'excus'));
}

public function update(UpdateExcuseRequest $request, Excuse $excus)
{
    $excus->update($request->all());

    $excuses = Excuse::with('user')->get();
    $users = User::whereIn('id', $excuses->pluck('user_id'))->get();
    $grouped = $excuses->groupBy('user_id');
    $sums = $grouped->map->sum(function($excuse) {
        $start = $excuse->start_date;
        $end =$excuse->end_date;
        return Carbon::parse($start)->diffInDays($end,false);
    });

    foreach ($users as $user) {
        $user->remaining_permit = $user->excuse_count - $sums[$user->id];
        $user->save();
    }

    return redirect()->route('admin.excuses.index');
}

public function show(Excuse $excus)
{
    abort_if(Gate::denies('excuse_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $excus->load('user', 'created_by');

    return view('admin.excuses.show', compact('excus'));
}

public function destroy(Excuse $excus)
{
    abort_if(Gate::denies('excuse_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $excus->delete();

    $excuses = Excuse::with('user')->get();
    $users = User::whereIn('id', $excuses->pluck('user_id'))->get();
    $grouped = $excuses->groupBy('user_id');
    $sums = $grouped->map->sum(function($excuse) {
        $start = $excuse->start_date;
        $end =$excuse->end_date;
        return Carbon::parse($start)->diffInDays($end,false);
    });

    foreach ($users as $user) {
        $user->remaining_permit = $user->excuse_count - $sums[$user->id];
        $user->save();
    }

    return back();
}

public function massDestroy(MassDestroyExcuseRequest $request)
{
    Excuse::whereIn('id', request('ids'))->delete();

    return response(null, Response::HTTP_NO_CONTENT);
}

}

Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

It's working with validation but I want disable the dates before the start date...

Sep
07
2 weeks ago
Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

Where should I put it? In my blade right?

Activity icon

Started a new Conversation How To Validate That End Date Is Greater Than Start Date

Hi,

I want to validate if the end date is ggreater than start date. I add a script in my page's blade but it doesn't work. What is the problem and also where should I put this script?

Here is my blade:

@extends('layouts.admin')

@section('content')

{{ trans('global.create') }} {{ trans('cruds.excuse.title_singular') }}
<div class="card-body">
    <form method="POST" action="{{ route("admin.excuses.store") }}" enctype="multipart/form-data">
        @csrf
        <div class="form-group">
            <label for="user_id">{{ trans('cruds.excuse.fields.user') }}</label>
            <select class="form-control select2 {{ $errors->has('user') ? 'is-invalid' : '' }}" name="user_id" id="user_id">
                @foreach($users as $id => $user)
                    <option value="{{ $id }}" {{ old('user_id') == $id ? 'selected' : '' }}>{{ $user }}</option>
                @endforeach
            </select>
            @if($errors->has('user'))
                <div class="invalid-feedback">
                    {{ $errors->first('user') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.user_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="start_date">{{ trans('cruds.excuse.fields.start_date') }}</label>
            <input class="form-control date {{ $errors->has('start_date') ? 'is-invalid' : '' }}" type="text" name="start_date" id="start_date" value="{{ old('start_date') }}">
            @if($errors->has('start_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('start_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.start_date_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="end_date">{{ trans('cruds.excuse.fields.end_date') }}</label>
            <input class="form-control date {{ $errors->has('end_date') ? 'is-invalid' : '' }}" type="text" name="end_date" id="end_date" value="{{ old('end_date') }}">
            @if($errors->has('end_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('end_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.end_date_helper') }}</span>
        </div>
        <div class="form-group">
            <button class="btn btn-danger" type="submit">
                {{ trans('global.save') }}
            </button>
        </div>
    </form>
</div>
@endsection

And here is my script at the end of my blade:

<script>
$(function(){
    $("#start_date").datepicker({
        numberOfMonths: 1,
        onSelect: function(selected) {
            $("#end_date").datepicker("option","minDate", selected)
        }
    });
    $("#end_date").datepicker({
        numberOfMonths: 1,
        onSelect: function(selected) {
            $("#start_date").datepicker("option","maxDate", selected)
        }
    });
});
Activity icon

Replied to Connection: Null Problem

Thank you!

Activity icon

Replied to Connection: Null Problem

I think I found the problem. By writing the terminal php artisan route:link, I get that the wanted URI is admin/excuses/{excus}/edit but the name is admin.excuses.edit.

I think the uri remove -es because it takes it plural. I hope I was able to explain my mind. How can I fix it?

Activity icon

Replied to Connection: Null Problem

I read the reference but I didn't understand where I'm doing wrong. Please check the code below. It is my edit.blade.php

<div class="card">
<div class="card-header">
    {{ trans('global.edit') }} {{ trans('cruds.excuse.title_singular') }}
</div>

<div class="card-body">
    <form method="POST" action="{{ route("admin.excuses.update", [$excuse->id]) }}" enctype="multipart/form-data">
        @method('PUT')
        @csrf
        <div class="form-group">
            <label for="user_id">{{ trans('cruds.excuse.fields.user') }}</label>
            <select class="form-control select2 {{ $errors->has('user') ? 'is-invalid' : '' }}" name="user_id" id="user_id">
                @foreach($users as $id => $user)
                    <option value="{{ $id }}" {{ ($excuse->user ? $excuse->user->id : old('user_id')) == $id ? 'selected' : '' }}>{{ $user }}</option>
                @endforeach
            </select>
            @if($errors->has('user'))
                <div class="invalid-feedback">
                    {{ $errors->first('user') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.user_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="start_date">{{ trans('cruds.excuse.fields.start_date') }}</label>
            <input class="form-control date {{ $errors->has('start_date') ? 'is-invalid' : '' }}" type="text" name="start_date" id="start_date" value="{{ old('start_date', $excuse->start_date) }}">
            @if($errors->has('start_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('start_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.start_date_helper') }}</span>
        </div>
        <div class="form-group">
            <label for="end_date">{{ trans('cruds.excuse.fields.end_date') }}</label>
            <input class="form-control date {{ $errors->has('end_date') ? 'is-invalid' : '' }}" type="text" name="end_date" id="end_date" value="{{ old('end_date', $excuse->end_date) }}">
            @if($errors->has('end_date'))
                <div class="invalid-feedback">
                    {{ $errors->first('end_date') }}
                </div>
            @endif
            <span class="help-block">{{ trans('cruds.excuse.fields.end_date_helper') }}</span>
        </div>
        <div class="form-group">
            <button class="btn btn-danger" type="submit">
                {{ trans('global.save') }}
            </button>
        </div>
    </form>
</div>

Here, I think I pass the true parameter:

<form method="POST" action="{{ route("admin.excuses.update", [$excuse->id]) }}" enctype="multipart/form-data">

And this is my update function in my controller:

public function update(UpdateExcuseRequest $request, Excuse $excuse)
{
    $excuse->update($request->all());

    return redirect()->route('admin.excuses.index');
}

Please let me know if you can find anything wrong!

Activity icon

Started a new Conversation Connection: Null Problem

Hi,

In my panel, when I try to edit, show or delete some data I get this error:

Illuminate\Routing\Exceptions\UrlGenerationException Missing required parameters for [Route: admin.excuses.update] [URI: admin/excuses/{excus}]. (View: C:\Users.....\resources\views\admin\excuses\edit.blade.php)

When I dump and die it, it shows that connection is null but in other cruds, there isn't this problem. In others, connection is set as mysql. Also when I try to create new "excuse" entry, it is successfully saved in database. But I cannot retrieve these data.

So, I didn't really understand why in only this "excuse" crud there is connection problem.

Here is my excuse controller:

class ExcuseController extends Controller

{

public function index(Request $request) { abort_if(Gate::denies('excuse_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    if ($request->ajax()) {
        $query = Excuse::with(['user', 'created_by'])->select(sprintf('%s.*', (new Excuse)->table));
        $table = Datatables::of($query);

        $table->addColumn('placeholder', '&nbsp;');
        $table->addColumn('actions', '&nbsp;');

        $table->editColumn('actions', function ($row) {
            $viewGate      = 'excuse_show';
            $editGate      = 'excuse_edit';
            $deleteGate    = 'excuse_delete';
            $crudRoutePart = 'excuses';

            return view('partials.datatablesActions', compact(
                'viewGate',
                'editGate',
                'deleteGate',
                'crudRoutePart',
                'row'
            ));
        });

        $table->editColumn('id', function ($row) {
            return $row->id ? $row->id : "";
        });
        $table->addColumn('user_name', function ($row) {
            return $row->user ? $row->user->name : '';
        });

        $table->rawColumns(['actions', 'placeholder', 'user']);

        return $table->make(true);
    }

    $users = User::get();
    $users = User::get();

    return view('admin.excuses.index', compact('users', 'users'));
}

public function create()
{
    abort_if(Gate::denies('excuse_create'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $users = User::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');

    return view('admin.excuses.create', compact('users'));
}

public function store(StoreExcuseRequest $request)
{
    $excuse = Excuse::create($request->all());

    $excuses = Excuse::with('user')->get();
    $users = User::whereIn('id', $excuses->pluck('user_id'))->get();
    $grouped = $excuses->groupBy('user_id');
    $sums = $grouped->map->sum(function($excuse) {
        $start = $excuse->start_date;
        $end =$excuse->end_date;
        return Carbon::parse($start)->diffInDays($end,false);
    });

    foreach ($users as $user) {
        $user->remaining_permit = $user->excuse_count - $sums[$user->id];
        $user->save();
    }

    return redirect()->route('admin.excuses.index');
}

public function edit(Excuse $excuse)
{
    abort_if(Gate::denies('excuse_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $users = User::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');

    $excuse->load('user', 'created_by');

    return view('admin.excuses.edit', compact('users', 'excuse'));
}

public function update(UpdateExcuseRequest $request, Excuse $excuse)
{
    $excuse->update($request->all());

    return redirect()->route('admin.excuses.index');
}

public function show(Excuse $excuse)
{
    abort_if(Gate::denies('excuse_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $excuse->load('user', 'created_by');

    return view('admin.excuses.show', compact('excuse'));
}

public function destroy(Excuse $excuse)
{
    abort_if(Gate::denies('excuse_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');

    $excuse->delete();

    return back();
}

public function massDestroy(MassDestroyExcuseRequest $request)
{
    Excuse::whereIn('id', request('ids'))->delete();

    return response(null, Response::HTTP_NO_CONTENT);
}

}

How can I solve this problem? Thank you in advance!

Sep
04
3 weeks ago
Activity icon

Replied to Illuminate\Routing\Exceptions\UrlGenerationException Missing Required Parameters For [Route: Admin.excuses.update]

I replaced it but it gives the same error. Also I added this info:

Also when I dump and die it, it shows that connection is null but in other fields there isn't this problem. In others, connection is mysql.

Activity icon

Replied to Illuminate\Routing\Exceptions\UrlGenerationException Missing Required Parameters For [Route: Admin.excuses.update]

Nothing changed unfortunately but I made an edit in my post please take a look!