Skip to content

Commit dcc330f

Browse files
committed
added query method on models
1 parent 9d79bcc commit dcc330f

33 files changed

+35
-34
lines changed

app/Console/Commands/AdminCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function handle()
4343
$email = $this->ask('Email Address');
4444
$password = $this->secret('Password');
4545

46-
Admin::create([
46+
Admin::query()->create([
4747
'email' => $email,
4848
'name' => $name,
4949
'password' => Hash::make($password),

app/Console/Commands/ConvertVideoForStreaming.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct()
4040
*/
4141
public function handle()
4242
{
43-
$video = Video::find($this->argument('id'));
43+
$video = Video::query()->find($this->argument('id'));
4444
$video->update([
4545
'status' => 'notready'
4646
]);

app/Http/Controllers/Frontend/PageController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function download(Request $request)
6868
public function channel($slug, Request $request)
6969
{
7070
return view('frontend.page.channel')->with([
71-
'channel' => Channel::where('slug', $slug)->firstOrFail()
71+
'channel' => Channel::query()->where('slug', $slug)->firstOrFail()
7272
]);
7373
}
7474
}

app/Http/Livewire/Backend/Admin/Modal/CreateAdmin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function submit()
4646
'password' => ['required', 'min:8', 'same:passwordConfirmation'],
4747
]);
4848

49-
Admin::create([
49+
Admin::query()->create([
5050
'email' => $validated['email'],
5151
'name' => $validated['name'],
5252
'password' => Hash::make($validated['password']),

app/Http/Livewire/Backend/Admin/Modal/EditAdmin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function closeModalOnClickAway(): bool
2525

2626
public function mount()
2727
{
28-
$this->model = Admin::find($this->admin_id);
28+
$this->model = Admin::query()->find($this->admin_id);
2929
$this->name = $this->model->name;
3030
$this->email = $this->model->email;
3131
}

app/Http/Livewire/Backend/Admin/Modal/ViewAdmin.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ViewAdmin extends ModalComponent
1010
public $admin_id;
1111

1212
public $name;
13+
1314
public $email;
1415

1516
public static function closeModalOnClickAway(): bool
@@ -19,7 +20,7 @@ public static function closeModalOnClickAway(): bool
1920

2021
public function mount()
2122
{
22-
$this->model = Admin::find($this->admin_id);
23+
$this->model = Admin::query()->find($this->admin_id);
2324
$this->name = $this->model->name;
2425
$this->email = $this->model->email;
2526
}

app/Http/Livewire/Backend/Channel/Modal/BanChannel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function closeModalOnClickAway(): bool
2121

2222
public function mount()
2323
{
24-
$this->model = Channel::find($this->channel_id);
24+
$this->model = Channel::query()->find($this->channel_id);
2525
}
2626

2727
public function render()

app/Http/Livewire/Backend/Channel/Modal/BanUser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function closeModalOnClickAway(): bool
2121

2222
public function mount()
2323
{
24-
$this->model = User::find($this->user_id);
24+
$this->model = User::query()->find($this->user_id);
2525
}
2626

2727
public function render()

app/Http/Livewire/Backend/Channel/Modal/BanVideo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function closeModalOnClickAway(): bool
2121

2222
public function mount()
2323
{
24-
$this->model = Video::find($this->video_id);
24+
$this->model = Video::query()->find($this->video_id);
2525
}
2626

2727
public function render()

app/Http/Livewire/Backend/Channel/Modal/UnBanChannel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function closeModalOnClickAway(): bool
1818

1919
public function mount()
2020
{
21-
$this->model = Channel::find($this->channel_id);
21+
$this->model = Channel::query()->find($this->channel_id);
2222
}
2323

2424
public function render()

app/Http/Livewire/Backend/Channel/Modal/UnBanUser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static function closeModalOnClickAway(): bool
1717

1818
public function mount()
1919
{
20-
$this->model = User::find($this->user_id);
20+
$this->model = User::query()->find($this->user_id);
2121
}
2222

2323
public function submit()

app/Http/Livewire/Backend/Channel/Modal/UnBanVideo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static function closeModalOnClickAway(): bool
1717

1818
public function mount()
1919
{
20-
$this->model = Video::find($this->video_id);
20+
$this->model = Video::query()->find($this->video_id);
2121
}
2222

2323
public function submit()

app/Http/Livewire/Backend/Channel/Modal/ViewVideo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static function closeModalOnClickAway(): bool
1717

1818
public function mount()
1919
{
20-
$this->video = Video::find($this->video_id);
20+
$this->video = Video::query()->find($this->video_id);
2121
}
2222

2323
public function render()

app/Http/Livewire/Frontend/Channel/Modal/CreateStream.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function submit()
3434
$streaming_url = "/live/{$stream_key}/index.m3u8";
3535
$media_id = Str::random(10);
3636

37-
$channel = Channel::find($this->channel_id);
37+
$channel = Channel::query()->find($this->channel_id);
3838
$video = $channel->videos()->create([
3939
'name' => $this->name,
4040
'description' => $this->description,

app/Http/Livewire/Frontend/Channel/Modal/EditChannel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function closeModalOnClickAway(): bool
2424

2525
public function mount()
2626
{
27-
$this->model = Channel::find($this->channel_id);
27+
$this->model = Channel::query()->find($this->channel_id);
2828
$this->name = $this->model->name;
2929
$this->slug = $this->model->slug;
3030
$this->active = $this->model->active;

app/Http/Livewire/Frontend/Channel/Modal/EditContent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function closeModalOnClickAway(): bool
2121

2222
public function mount()
2323
{
24-
$this->model = Video::find($this->video_id);
24+
$this->model = Video::query()->find($this->video_id);
2525
$this->name = $this->model->name;
2626
$this->description = $this->model->description;
2727
}

app/Http/Livewire/Frontend/Channel/Modal/ViewContent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function closeModalOnClickAway(): bool
3232

3333
public function mount()
3434
{
35-
$this->video = Video::find($this->video_id);
35+
$this->video = Video::query()->find($this->video_id);
3636
}
3737

3838
public function render()

app/Http/Livewire/Frontend/Channel/Partial/Analytic.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function mount()
2020

2121
public function getData()
2222
{
23-
$this->video = Video::find($this->video_id);
23+
$this->video = Video::query()->find($this->video_id);
2424
$this->subscribed_user_views = views($this->video)->unique()->collection('subscribed')->count();
2525
$this->unsubscribed_user_views = views($this->video)->unique()->collection('unsubscribed')->count();
2626
$this->total_views = $this->subscribed_user_views + $this->unsubscribed_user_views;

app/Http/Livewire/Frontend/Channel/Partial/ChannelAnalytics.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function mount()
1818

1919
public function getData()
2020
{
21-
$this->channel = Channel::find($this->channel_id);
21+
$this->channel = Channel::query()->find($this->channel_id);
2222
$this->count = $this->channel->subscribers()->count();
2323
}
2424

app/Http/Livewire/Frontend/Channel/Partial/Settings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Settings extends Component
1313

1414
public function mount()
1515
{
16-
$this->video = Video::find($this->video_id);
16+
$this->video = Video::query()->find($this->video_id);
1717
$this->settings['allow_comments'] = $this->video->settings()->get('allow_comments', true);
1818
$this->settings['allow_download'] = $this->video->settings()->get('allow_download', true);
1919
}

app/Http/Livewire/Frontend/Channel/Partial/Thumbnail.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Thumbnail extends Component
2020

2121
public function mount()
2222
{
23-
$this->video = Video::find($this->video_id);
23+
$this->video = Video::query()->find($this->video_id);
2424
// $this->getThumbnailsList();
2525
}
2626

app/Http/Livewire/Frontend/Channel/ViewChannel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function updateTab($tab)
9494

9595
public function mount()
9696
{
97-
$this->channel = Channel::find($this->channel_id);
97+
$this->channel = Channel::query()->find($this->channel_id);
9898
}
9999

100100
public function render()

app/Http/Livewire/Frontend/Components/ChannelOwnerButton.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function mount()
1717

1818
public function getData()
1919
{
20-
$this->channel = Channel::find($this->channel_id);
20+
$this->channel = Channel::query()->find($this->channel_id);
2121
}
2222

2323
public function render()

app/Http/Livewire/Frontend/Components/ChannelProfile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function mount()
3030

3131
public function getData()
3232
{
33-
$this->channel = Channel::find($this->channel_id);
33+
$this->channel = Channel::query()->find($this->channel_id);
3434
$this->name = $this->channel->name;
3535
$this->picture = Storage::disk($this->channel->disk)->url($this->channel->profile_picture);
3636
$this->count = $this->channel->subscribers()->count();

app/Http/Livewire/Frontend/Components/Comment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function loadMore()
4343

4444
public function getData()
4545
{
46-
$this->video = Video::find($this->video_id);
46+
$this->video = Video::query()->find($this->video_id);
4747
}
4848

4949
public function submit()

app/Http/Livewire/Frontend/Components/LikeDislikeButton.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function mount()
2828

2929
public function getData()
3030
{
31-
$this->video = Video::find($this->video_id);
31+
$this->video = Video::query()->find($this->video_id);
3232
}
3333

3434
public function likeVideo()

app/Http/Livewire/Frontend/Components/SubscribeButton.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function mount()
2626

2727
public function getData()
2828
{
29-
$this->channel = Channel::find($this->channel_id);
29+
$this->channel = Channel::query()->find($this->channel_id);
3030
$this->subscribe = auth()->check() ? auth()->user()->hasSubscribed($this->channel) : false;
3131
}
3232

app/Http/Livewire/Frontend/Video/ChannelVideo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function loadMore()
2727

2828
public function mount()
2929
{
30-
$this->channel = Channel::find($this->channel_id);
30+
$this->channel = Channel::query()->find($this->channel_id);
3131
}
3232

3333
public function render()

app/Http/Livewire/Frontend/Video/Modal/DeleteComment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function render()
2323

2424
public function submit()
2525
{
26-
$comment = Comment::find($this->comment_id);
26+
$comment = Comment::query()->find($this->comment_id);
2727
$comment->delete();
2828

2929
broadcast(new DynamicChannel("{$comment->commentable->media_id}.video.comments"));

app/Http/Livewire/Frontend/Video/Modal/EditComment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function closeModalOnClickAway(): bool
2020

2121
public function mount()
2222
{
23-
$this->comment = Comment::find($this->comment_id);
23+
$this->comment = Comment::query()->find($this->comment_id);
2424
$this->message = $this->comment->comment;
2525
}
2626

app/Http/Livewire/Frontend/Video/Modal/ReplyComment.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function closeModalOnClickAway(): bool
2525

2626
public function mount()
2727
{
28-
$this->p_comment = Comment::find($this->comment_id);
28+
$this->p_comment = Comment::query()->find($this->comment_id);
2929
}
3030

3131
public function render()
@@ -39,7 +39,7 @@ public function submit()
3939
'message' => 'required|string'
4040
]);
4141

42-
$commenter = $this->owner ? Channel::find($this->commenter['id']) : auth()->user();
42+
$commenter = $this->owner ? Channel::query()->find($this->commenter['id']) : auth()->user();
4343

4444
$rc = new Comment();
4545
$rc->parent()->associate($this->p_comment);

app/Listeners/TusEventListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function handleUploadCompleted($event)
2525
$duration = Str::contains($file['metadata']['type'],['video/x-matroska']) ? 0 : getVideoDurationInSeconds($path);
2626
$filesystem = config('site.converted_file_driver');
2727

28-
$channel = Channel::find($file['metadata']['channel']);
28+
$channel = Channel::query()->find($file['metadata']['channel']);
2929
$channel->videos()->create([
3030
'name' => 'untitled video',
3131
'media_id' => Str::random(10),

search_replace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
2 => [
1212
"in_array" => [
13-
'where', 'count', 'find', 'findOrNew', 'findOrFail'
13+
'where', 'count', 'find', 'findOrNew', 'create', 'findOrFail'
1414
]
1515
]
1616
]

0 commit comments

Comments
 (0)